views:

548

answers:

2

Is there a simple way to order rows with unicode data in SQLite?

+1  A: 

There is a library called ICU that can do proper unicode sorting for you; there's a good description in this other question:

http://stackoverflow.com/questions/611459/how-to-sort-text-in-sqlite3-with-specified-locale

Will
+3  A: 

SQLite has a BYOS (Bring Your Own Sorter) policy. See the FAQ for more details. They chose not to include (by default) any Unicode-aware sorting algorithm, to keep the SQLite library svelte and easy to statically link in.

However, you can create a collator, that sorts however you please, then tell SQLite to use it. As the other poster hinted at, there are collators in the source tree that do this using ICU. However, you can also use your own, which makes sense if you're using a library like GLib that has its own Unicode-awareness.

Matthew Flaschen