mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-10 12:47:26 +01:00
parent
e1ab1fdb65
commit
224f29077d
@ -266,11 +266,15 @@ class LibraryPresenter(
|
|||||||
val collator = Collator.getInstance(locale).apply {
|
val collator = Collator.getInstance(locale).apply {
|
||||||
strength = Collator.PRIMARY
|
strength = Collator.PRIMARY
|
||||||
}
|
}
|
||||||
|
val sortAlphabetically: (LibraryItem, LibraryItem) -> Int = { i1, i2 ->
|
||||||
|
collator.compare(i1.libraryManga.manga.title.lowercase(locale), i2.libraryManga.manga.title.lowercase(locale))
|
||||||
|
}
|
||||||
|
|
||||||
val sortFn: (LibraryItem, LibraryItem) -> Int = { i1, i2 ->
|
val sortFn: (LibraryItem, LibraryItem) -> Int = { i1, i2 ->
|
||||||
val sort = sortModes[i1.libraryManga.category]!!
|
val sort = sortModes[i1.libraryManga.category]!!
|
||||||
when (sort.type) {
|
when (sort.type) {
|
||||||
LibrarySort.Type.Alphabetical -> {
|
LibrarySort.Type.Alphabetical -> {
|
||||||
collator.compare(i1.libraryManga.manga.title.lowercase(locale), i2.libraryManga.manga.title.lowercase(locale))
|
sortAlphabetically(i1, i2)
|
||||||
}
|
}
|
||||||
LibrarySort.Type.LastRead -> {
|
LibrarySort.Type.LastRead -> {
|
||||||
i1.libraryManga.lastRead.compareTo(i2.libraryManga.lastRead)
|
i1.libraryManga.lastRead.compareTo(i2.libraryManga.lastRead)
|
||||||
@ -308,7 +312,7 @@ class LibraryPresenter(
|
|||||||
Collections.reverseOrder(sortFn)
|
Collections.reverseOrder(sortFn)
|
||||||
}
|
}
|
||||||
|
|
||||||
entry.value.sortedWith(comparator)
|
entry.value.sortedWith(comparator.thenComparator(sortAlphabetically))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user