Question

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

Was it helpful?

Solution

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.

OTHER TIPS

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

How to sort text in sqlite3 with specified locale?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top