I have just found out something very curious in PostgreSQL. Suppose we have a column "name" with values like
bbb
(ccc)
aaa
(eee)
ddd
If I do a SELECT (...) ORDER BY name ASC, the result is
aaa
bbb
(ccc)
ddd
(eee)
That was very clever, but what I had previously in MySQL (and what I really want now) is
(ccc)
(eee)
aaa
bbb
ddd
Any idea why that happens and how can I fix it?
Edit: as mentioned in the comments, it looks like the guilty lies on the en_US.UTF-8 collation. But I need it to correctly sort strings with latin characters. So is there any regex or an alternative collation to solve the problem?
(ccc)as the first row. Maybe some collation setting?order by regexp_replace(the_column, '[^a-zA-Z]', '')