Skip to content

Sort the library ignoring case and accents - #17

Merged
hatstand merged 3 commits into
mainfrom
claude/library-sort-case
Sep 30, 2026
Merged

hatstand merged 3 commits into
mainfrom
claude/library-sort-case

Conversation

@hatstand

Copy link
Copy Markdown

The library ordered names the way SQLite does by default, by their bytes, so "abba" came after "ZZ Top", and "Émile" after both.

  • Database now registers a LOCALIZED collation on every connection it opens. It compares with localizedStandardCompare, which iOS search results already use. Names that differ only in case get a fixed order between them, so the list is always in the same order.
  • SongQuery orders each level with it: ORDER BY <field> COLLATE LOCALIZED, and for songs ORDER BY album COLLATE LOCALIZED, disc, track, so an album's songs stay in track order.

The collation is named after the one Android's SQLite has built in, so both clients run the same SQL. The Android change is clementine-player/Android-Remote#293.

I couldn't build this: my environment has no Swift toolchain. The new sortsIgnoringCaseAndAccents test checks the same cases as the Android test (artists both ways, albums, an album's songs), and the package job in CI runs it with swift test.

🤖 Generated with Claude Code

https://claude.ai/code/session_012foWs5vBJrYTDtfyFhJ3ky


Generated by Claude Code

The library ordered names by their bytes, as SQLite does, so "abba" came
after "ZZ Top", and "Émile" after both. The database now has a
LOCALIZED collation that orders text as the phone's language does, as
search results are, and the library's levels are ordered with it. It's
named as the one Android's SQLite has, so both clients use the same SQL.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012foWs5vBJrYTDtfyFhJ3ky
The library test expected "Apple" before "apple", but the order of names
differing only in case is the language's to choose, and on iOS it isn't
that one. It now checks they're side by side, before the rest.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012foWs5vBJrYTDtfyFhJ3ky
@hatstand
hatstand disabled auto-merge September 30, 2026 09:55
localizedStandardCompare told names differing only in case apart in its
own order, not Android's. The LOCALIZED collation now compares ignoring
case only, and the library then orders equal names by their bytes, as
the Android client does, so "Apple" always comes before "apple".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012foWs5vBJrYTDtfyFhJ3ky
@github-actions

Copy link
Copy Markdown

Screenshots

From run 36699370934, against a real Clementine. Left: main. Right: this pull request, light and dark.

Screen main This PR This PR, dark
01_connect
02_queue
03_player
04_connection
05_settings
06_library
07_library_album
08_search
09_outputs
10_internet
11_internet_radio

@hatstand
hatstand merged commit b2b5d98 into main Sep 30, 2026
4 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