mirror of
https://github.com/SimpleMobileTools/Simple-Notes.git
synced 2025-03-23 03:50:07 +01:00
sort notes properly, including accents
This commit is contained in:
parent
16229704ea
commit
63e75ec2d8
@ -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 {
|
||||||
|
@ -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")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user