sort notes properly, including accents

This commit is contained in:
tibbi 2023-08-02 15:42:54 +02:00
parent 16229704ea
commit 63e75ec2d8
2 changed files with 4 additions and 2 deletions

View File

@ -7,7 +7,7 @@ import java.text.Collator
* *
* Adapted from AlphanumericComparator to support numerical collation. * Adapted from AlphanumericComparator to support numerical collation.
*/ */
class CollatorBasedComparator: Comparator<String> { class CollatorBasedComparator : Comparator<String> {
override fun compare(string1: String, string2: String): Int { override fun compare(string1: String, string2: String): Int {
val collator = getCollator() val collator = getCollator()
@ -64,10 +64,12 @@ class CollatorBasedComparator: Comparator<String> {
chunk.append(c) chunk.append(c)
current++ current++
} }
return chunk.toString() return chunk.toString()
} }
private fun isDigit(ch: Char) = ch in '0'..'9' private fun isDigit(ch: Char) = ch in '0'..'9'
private fun coerceResult(compareToResult: Int) = compareToResult.coerceIn(-1, 1) private fun coerceResult(compareToResult: Int) = compareToResult.coerceIn(-1, 1)
private fun getCollator(): Collator { private fun getCollator(): Collator {

View File

@ -5,7 +5,7 @@ import com.simplemobiletools.notes.pro.models.Note
@Dao @Dao
interface NotesDao { interface NotesDao {
@Query("SELECT * FROM notes ORDER BY title COLLATE NOCASE ASC") @Query("SELECT * FROM notes ORDER BY title COLLATE UNICODE ASC ")
fun getNotes(): List<Note> fun getNotes(): List<Note>
@Query("SELECT * FROM notes WHERE id = :id") @Query("SELECT * FROM notes WHERE id = :id")