I had this query:
SELECT * FROM table ORDER BY label ASC;
Since the labels are not in English, they didn't get sorted in the right order (ones beginning with "ö" were not in the bottom/end).
I therefore tried:
SELECT * FROM table ORDER BY label COLLATE "sv-SE" ASC;
SELECT * FROM table ORDER BY label COLLATE "sv_SE" ASC;
These gave errors about those collations not existing, which baffled me.
After a bunch of searching, I figured out to do:
SELECT * FROM pg_collation;
Which revealed that it's supposed to be:
sv-SE-x-icu
It worked when I used that identifier, but what's with the "-x-icu" stuff? What's that all about? I hate that they always have to mess with the standard locale identifiers so you can never rely on just the standard "language_location" format.
Best Answer
The documentation, 23.2. Collation Support / 23.2.2.2.2. ICU Collations , states:
ICU is the "International Components for Unicode", which, according to their homepage, is:
Unicode is a specification, not software, hence for many years each vendor has implemented it on their own and thus there is not nearly as much consistency anyone working with collations would appreciate. The ICU project is, quite fortunately, being implemented by more and more vendors, which is improving Unicode support and consistency. If available, I would expect the ICU collations to be a better choice than non-ICU collations.