Fix name sorting by splitting on symbols instead of removing them

Change IntelligentKnownName tokenizer to replace punctuation with spaces
instead of removing them. This creates token boundaries at symbol positions,
fixing sorting of names like "15-9" vs "15-10" which were previously being
compared as single numbers (159 vs 1510).

Fixes issue where hyphenated numbers like 15-10 appeared after 20-4
instead of after 15-9.

Co-authored-by: OxygenCobalt <65370175+OxygenCobalt@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-01-11 01:46:09 +00:00
co-authored by OxygenCobalt
parent 893024c239
commit 0c2e1a3fbd
2 changed files with 29 additions and 9 deletions
@@ -86,10 +86,10 @@ private data class IntelligentKnownName(override val raw: String, override val s
// optimize it
val stripped =
name
// Remove excess punctuation from the string, as those usually aren't
// considered in sorting.
.replace(punctRegex, "")
.ifEmpty { name }
// Replace punctuation with spaces to create token boundaries, improving
// sorting of names like "15-9" vs "15-10".
.replace(punctRegex, " ")
.let { if (it.isBlank()) name else it }
.run {
// Strip any english articles like "the" or "an" from the start, as music
// sorting should ignore such when possible.