Body: <p>We are using a localised installation (Swedish) but names, e.g. in searches, are not sorted according to the localized order. E.g</p>
  <p><a href="https://i.sstatic.net/R87t0.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/R87t0.png" alt="enter image description here" /></a></p>
  <p>In this example the names starting with 'Å' should be sorted at the end of the alphabet.</p>
  <p>How do we get the sorting sorted ;-)</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-03-07T20:41:06.377Z
Comments.Text: I've no instant idea where in the code/data access layer the sorting is done but if I were you I'd try a DB search directly to find out if mysql's collation is the reason. I can't imagine that big paged data sets like civicrm's search reults are ordered in php. So maybe it's just a matter of changing mysql utf8_general_ci to utf8_swedish_ci.
Comments.UserDisplayName: nielo
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-03-07T21:09:34.787Z
Comments.Text: Right! We have charset `utf8mb4` with collation `utf8mb4_unicode_ci`. Since `utf8mb4_swedish_ci` has the same charset, changing it should be no problem, right? Make that into an answer, while I take a db backup and try it ;-)
Comments.UserDisplayName: thoni56
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-03-08T07:58:27.897Z
Comments.Text: Cool. Did u try?
Comments.UserDisplayName: nielo
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-03-08T14:28:22.993Z
Comments.Text: Tried it on 'civicrm_contact' and it seems to be working. Pondering if I should do that for all tables... Collation can be defined on column, table, database, connection and server level so it seems like some general approach would be preferable to be able to change it depending on language of installation rather than "hardcoding" it in the tables...
Comments.UserDisplayName: thoni56
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-03-08T20:34:03.933Z
Comments.Text: "Pondering" is nicely shortened for riding a real wild horse on https://en.wikipedia.org/wiki/Ponderosa_Ranch! And yes, I would do that for all. That's what collation is for.
Comments.UserDisplayName: nielo
Tags: <localisation><sort-order>
Title: How do we get names sorted according to localised setting?
ThreadText: # How do we get names sorted according to localised setting?
  
  (Asked by: username_0 on 2023-03-06)
  
  We are using a localised installation (Swedish) but names, e.g. in searches, are not sorted according to the localized order. E.g
  
  [![enter image description here](https://i.sstatic.net/R87t0.png)](https://i.sstatic.net/R87t0.png)
  
  In this example the names starting with 'Å' should be sorted at the end of the alphabet.
  
  How do we get the sorting sorted ;-)
  
  **Tags:** localisation, sort-order
  
  > **Comments:**
  > **username_1**: I've no instant idea where in the code/data access layer the sorting is done but if I were you I'd try a DB search directly to find out if mysql's collation is the reason. I can't imagine that big paged data sets like civicrm's search reults are ordered in php. So maybe it's just a matter of changing mysql utf8_general_ci to utf8_swedish_ci.  
  > **username_0**: Right! We have charset `utf8mb4` with collation `utf8mb4_unicode_ci`. Since `utf8mb4_swedish_ci` has the same charset, changing it should be no problem, right? Make that into an answer, while I take a db backup and try it ;-)  
  > **username_1**: Cool. Did u try?  
  > **username_0**: Tried it on 'civicrm_contact' and it seems to be working. Pondering if I should do that for all tables... Collation can be defined on column, table, database, connection and server level so it seems like some general approach would be preferable to be able to change it depending on language of installation rather than "hardcoding" it in the tables...  
  > **username_1**: "Pondering" is nicely shortened for riding a real wild horse on https://en.wikipedia.org/wiki/Ponderosa_Ranch! And yes, I would do that for all. That's what collation is for.  
  
  ---
  
  ## 0 answers
  
  