From f057440cc1ebfc62bd1d3b85b284781ea9bce9bc Mon Sep 17 00:00:00 2001 From: arkon Date: Sat, 16 Oct 2021 17:37:41 -0400 Subject: [PATCH] Use natural ordering when sorting by chapter numbers (fixes #6121) --- .../java/eu/kanade/tachiyomi/util/chapter/ChapterSorter.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/chapter/ChapterSorter.kt b/app/src/main/java/eu/kanade/tachiyomi/util/chapter/ChapterSorter.kt index bce8fc6cb3..764f00491c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/chapter/ChapterSorter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/chapter/ChapterSorter.kt @@ -2,6 +2,7 @@ package eu.kanade.tachiyomi.util.chapter import eu.kanade.tachiyomi.data.database.models.Chapter import eu.kanade.tachiyomi.data.database.models.Manga +import eu.kanade.tachiyomi.util.lang.compareToCaseInsensitiveNaturalOrder fun getChapterSort(manga: Manga, sortDescending: Boolean = manga.sortDescending()): (Chapter, Chapter) -> Int { return when (manga.sorting) { @@ -10,8 +11,8 @@ fun getChapterSort(manga: Manga, sortDescending: Boolean = manga.sortDescending( false -> { c1, c2 -> c2.source_order.compareTo(c1.source_order) } } Manga.CHAPTER_SORTING_NUMBER -> when (sortDescending) { - true -> { c1, c2 -> c2.chapter_number.compareTo(c1.chapter_number) } - false -> { c1, c2 -> c1.chapter_number.compareTo(c2.chapter_number) } + true -> { c1, c2 -> c2.chapter_number.toString().compareToCaseInsensitiveNaturalOrder(c1.chapter_number.toString()) } + false -> { c1, c2 -> c1.chapter_number.toString().compareToCaseInsensitiveNaturalOrder(c2.chapter_number.toString()) } } Manga.CHAPTER_SORTING_UPLOAD_DATE -> when (sortDescending) { true -> { c1, c2 -> c2.date_upload.compareTo(c1.date_upload) }