Skip to content

Sort the library ignoring case and accents - #293

Merged
hatstand merged 2 commits into
masterfrom
claude/library-sort-case
Sep 30, 2026
Merged

hatstand merged 2 commits into
masterfrom
claude/library-sort-case

Conversation

@hatstand

@hatstand hatstand commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

The library ordered names the way SQLite does by default, by their bytes, so "abba" came after "ZZ Top", and "Émile" after both. DynamicSongQuery now orders each level with Android SQLite's built-in ICU collation, COLLATE LOCALIZED, which sorts the way the phone's language does, like search results. SQLite's own NOCASE wasn't enough: it only folds ASCII.

  • Artists, albums, genres and so on: ORDER BY <field> COLLATE LOCALIZED ASC|DESC.
  • Songs: ORDER BY album COLLATE LOCALIZED, disc, track, so an album's songs stay in track order.
  • Years are numbers, so the collation doesn't affect them.
  • Grouping is unchanged: names that differ only in case are still separate items, now next to each other.

The library database isn't opened with NO_LOCALIZED_COLLATORS, so the collation is available on read-only connections.

The iOS client gets the same change in clementine-player/iOS-Remote#17. It registers a collation of the same name, so both clients run the same SQL.

Tests: the new DynamicSongQueryTest covers:

  • artists ascending and descending;
  • one artist's albums;
  • an album's songs staying in track order despite their titles.

It failed against the old query and passes with the new one. LibraryScreenTest and SearchScreenTest still pass.

🤖 Generated with Claude Code

https://claude.ai/code/session_012foWs5vBJrYTDtfyFhJ3ky

The library ordered names by their bytes, as SQLite does, so "abba" came
after "ZZ Top", and "Émile" after both. It now orders them with the
LOCALIZED collation Android's SQLite has, as the phone's language does,
the way search results are ordered. Songs stay in disc and track order.

Release-note: The library lists artists and albums in alphabetical order, whatever their case or accents.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012foWs5vBJrYTDtfyFhJ3ky
After ordering names with the LOCALIZED collation, the library orders
equal names by their bytes, so names differing only in case are in a
fixed order, "Apple" before "apple", whatever the device's collation
makes of them. The iOS client does the same.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012foWs5vBJrYTDtfyFhJ3ky
@hatstand
hatstand merged commit 8514f2d into master Sep 30, 2026
5 checks passed
@hatstand
hatstand deleted the claude/library-sort-case branch September 30, 2026 10:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants