From 224f29077d37ca72c5a9f01649998c80d7bafedd Mon Sep 17 00:00:00 2001 From: arkon Date: Sat, 29 Oct 2022 10:11:12 -0400 Subject: [PATCH] Sort library items alphabetically in secondary pass Fixes #7461 --- .../eu/kanade/tachiyomi/ui/library/LibraryPresenter.kt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.kt index 8ae33d93a..988b54e20 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.kt @@ -266,11 +266,15 @@ class LibraryPresenter( val collator = Collator.getInstance(locale).apply { 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 sort = sortModes[i1.libraryManga.category]!! when (sort.type) { LibrarySort.Type.Alphabetical -> { - collator.compare(i1.libraryManga.manga.title.lowercase(locale), i2.libraryManga.manga.title.lowercase(locale)) + sortAlphabetically(i1, i2) } LibrarySort.Type.LastRead -> { i1.libraryManga.lastRead.compareTo(i2.libraryManga.lastRead) @@ -308,7 +312,7 @@ class LibraryPresenter( Collections.reverseOrder(sortFn) } - entry.value.sortedWith(comparator) + entry.value.sortedWith(comparator.thenComparator(sortAlphabetically)) } }