music: remove zero digit-likes from names

Remove all characters with a semantic meaning of "zero" from the start
of music names, at least when intelligent sorting is enabled.
This commit is contained in:
Alexander Capehart 2023-06-08 14:09:09 -06:00
parent 93d3e82140
commit e848bea0bf
No known key found for this signature in database
GPG key ID: 37DBE3621FE9AD47

View file

@ -203,8 +203,7 @@ private data class IntelligentKnownName(override val raw: String, override val s
// Separate each token into their numeric and lexicographic counterparts. // Separate each token into their numeric and lexicographic counterparts.
if (token.first().isDigit()) { if (token.first().isDigit()) {
// The digit string comparison breaks with preceding zero digits, remove those // The digit string comparison breaks with preceding zero digits, remove those
// TODO: Handle zero digits in other languages val digits = token.trimStart { Character.getNumericValue(it) == 0 }.ifEmpty { token }
val digits = token.trimStart('0').ifEmpty { token }
// Other languages have other types of digit strings, still use collation keys // Other languages have other types of digit strings, still use collation keys
collationKey = COLLATOR.getCollationKey(digits) collationKey = COLLATOR.getCollationKey(digits)
type = SortToken.Type.NUMERIC type = SortToken.Type.NUMERIC