Just take a look, please:
WITH toks AS (
SELECT tok
FROM
unnest('{ь, а, чь, ча, чль, чла}'::text[]) AS tok
ORDER BY tok COLLATE "uk_UA"
)
SELECT ROW_NUMBER() OVER() AS "#", tok FROM toks
ORDER BY tok COLLATE "uk_UA"
PostgreSQL 9.3 (ubuntu) gives me this result:
# | tok
---+-----
1 | а
2 | ча
3 | чль
4 | чла
5 | чь
6 | ь
(6 rows)
Here rows 1, 2, 5 and 6 are sorted properly ("ь" goes after "а") while rows 3 and 4 are sorted wrongly ("а" goes after "ь").
All letters are Cyrillic, I've checked so many times.
Please, what's wrong and how to workaround .(
UPDATE: this is a bug which was fixed in mainstream recently: https://sourceware.org/bugzilla/show_bug.cgi?id=17293
UPDATE2: Please note my own answer below.
sort
utility with the same collation and the same data, that should output the same order. – Daniel Vérité Jun 30 '15 at 10:45sort
gives somewhat different but wrong result also:ь > а
butть < та
. So, there is somewhere an issue with system's locale? – brownian Jun 30 '15 at 11:06export LANG=uk_UA
---sort
ing seems to be ok; there is a problem with defaultLANG=uk_UA.UTF-8
. – brownian Jun 30 '15 at 11:17