diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 2dbc423c9b..07b50be4c8 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -209,6 +209,9 @@ dependencies { // Logging implementation("com.jakewharton.timber:timber:${Versions.TIMBER}") + // Sort + implementation("com.github.gpanther:java-nat-sort:natural-comparator-1.1") + // UI implementation("com.dmitrymalkovich.android:material-design-dimens:1.4") implementation("br.com.simplepass:loading-button-android:2.2.0") diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/lang/StringExtensions.kt b/app/src/main/java/eu/kanade/tachiyomi/util/lang/StringExtensions.kt index 2ea9ef383e..e3f79ffb50 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/lang/StringExtensions.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/lang/StringExtensions.kt @@ -15,6 +15,7 @@ import androidx.annotation.ColorInt import androidx.annotation.StringRes import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.util.system.getResourceColor +import net.greypanther.natsort.CaseInsensitiveSimpleNaturalComparator import kotlin.math.floor /** @@ -89,7 +90,8 @@ fun String.capitalizeWords(): String { * Case-insensitive natural comparator for strings. */ fun String.compareToCaseInsensitiveNaturalOrder(other: String): Int { - return String.CASE_INSENSITIVE_ORDER.then(naturalOrder()).compare(this, other) + val comparator = CaseInsensitiveSimpleNaturalComparator.getInstance() + return comparator.compare(this, other) } fun CharSequence.tintText(@ColorInt color: Int): Spanned {