Tweak string comparison to account for length (fixes #2831)

This commit is contained in:
arkon 2020-04-07 21:40:36 -04:00
parent ea75f63dfb
commit d5350fd719

View file

@ -30,7 +30,9 @@ fun String.truncateCenter(count: Int, replacement: String = "..."): String {
* Case-insensitive natural comparator for strings. * Case-insensitive natural comparator for strings.
*/ */
fun String.compareToCaseInsensitiveNaturalOrder(other: String): Int { fun String.compareToCaseInsensitiveNaturalOrder(other: String): Int {
return String.CASE_INSENSITIVE_ORDER.then(naturalOrder()).compare(this, other) return compareBy<String> { it.length }
.then(String.CASE_INSENSITIVE_ORDER)
.then(naturalOrder()).compare(this, other)
} }
/** /**