Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do databases sort Chinese characters?

I am currently writing a web app and will need to do some ordering on a set of Chinese characters and I want to know whether Chinese characters are sorted by databases, if so how does it get sorted?

For reference I will be using PostgreSQL.

like image 342
bash- Avatar asked Feb 18 '26 22:02

bash-


1 Answers

PostgreSQL sorts text using the operating system locale facility. This is exactly the same behavior that operating system tools such as sort give you. So set your locale to something useful, such as zh_HK.utf8 when you initialize the database system.

If you don't like the results of that sort, you'll have to come with a custom solution.

like image 138
Peter Eisentraut Avatar answered Feb 21 '26 14:02

Peter Eisentraut