ORDER BY alphanumeric characters only in SQLite

后端 未结 5 1150
再見小時候
再見小時候 2021-02-05 15:24

I am sorting songs in SQLite (on Android). I want to order them:

  1. Case-insensitive
  2. With leading-digits at the end, by integer value.
  3. Without punct
5条回答
  •  醉梦人生
    2021-02-05 15:45

    You can use the sqlite3 Android NDK Bindings to gain access to the full sqlite3 c API by using JNI calls.

    Then you can Define New Collating Sequences by using the sqlite3_create_collation_v2() and related functions.

    This approach does not change the database, as the collation is only overridden on the current database connection. So it satisfies that requirement in that it works if the database is read-only.

    Notice I say you can. I'm not saying you SHOULD! Weigh the pros and cons of this approach as in most cases it is probably not worth the extra effort.

提交回复
热议问题