SQLite sort special characters alphabetically

I'm building an application that is used to teach people French. When I try to sort some French words do not end up where I intended them to be, for example:

  • Aller
  • Boire
  • En
  • Être
  • Vouloir
  • Will be sorted in the following order:

  • Aller
  • Boire
  • En
  • Vouloir
  • Être
  • The SQL statement I'm currently using is:

    SELECT name, assignment_id FROM GrammarAssignments ORDER BY name COLLATE NOCASE
    

    Just in case some one else comes across this post, I ran into the same issue and tested it. The below should do the trick of sorting depending on the locale as well as sorting case insensitive.

    SELECT name, assignment_id FROM GrammarAssignments ORDER BY name COLLATE LOCALIZED ASC
    

    Android's SQLite implementation has the LOCALIZED and UNICODE collations for this.

    See the SQLite documentation for how to apply collations to table columns and SQL expressions.

    链接地址: http://www.djcxy.com/p/65730.html

    上一篇: 检查选定行是否是表中最后一个可见行

    下一篇: SQLite按字母顺序排列特殊字符