Sort library items alphabetically in secondary pass

Fixes #7461

(cherry picked from commit 224f29077d37ca72c5a9f01649998c80d7bafedd)
This commit is contained in:
arkon 2022-10-29 10:11:12 -04:00 committed by Jobobby04
parent 51dd8c2285
commit f3a2b1d7e4

View File

@ -401,6 +401,10 @@ 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 ->
// SY --> // SY -->
val sort = when (groupType) { val sort = when (groupType) {
@ -410,7 +414,7 @@ class LibraryPresenter(
// SY <-- // SY <--
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)
@ -462,7 +466,7 @@ class LibraryPresenter(
Collections.reverseOrder(sortFn) Collections.reverseOrder(sortFn)
} }
entry.value.sortedWith(comparator) entry.value.sortedWith(comparator.thenComparator(sortAlphabetically))
} }
} }