fix(sorting): accent-aware library sorting with COLLATE LOCALIZED#2467
Open
AmrEldeeb5 wants to merge 1 commit into
Open
fix(sorting): accent-aware library sorting with COLLATE LOCALIZED#2467AmrEldeeb5 wants to merge 1 commit into
AmrEldeeb5 wants to merge 1 commit into
Conversation
Library sort queries ordered text with COLLATE NOCASE, which only case-folds ASCII A-Z and otherwise sorts by Unicode code point. Accented Latin letters (e.g. "A" with acute, U+00C1) sort after "Z", so titles like "Aguas De Marco" landed at the bottom of the list instead of under "A". Switch the title/artist/album/name ORDER BY clauses to COLLATE LOCALIZED, which is registered by Android's framework SQLite (used here via the default Room open-helper, so no new dependency) and orders accented characters in their expected position, locale-aware. Only query text changes, so no schema migration is required. The case-insensitive search filter in MediaStoreSongRepository is left untouched. Fixes PixelPlayerHQ#2164 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2164
Problem
Titles starting with accented letters (e.g. "Águas De Março") sort after Z instead of under A.
Cause
All library
ORDER BYclauses inMusicDaoorder text withCOLLATE NOCASE.NOCASEonly case-folds ASCIIA–Z; everything else falls back to code-point order, and accented Latin letters sit abovezin Unicode (Á= U+00C1 >z= U+007A).Fix
Use
COLLATE LOCALIZEDfor the text orderings (title / artist / album / name) across the songs, albums, artists, liked, and folder queries.LOCALIZEDis registered by Android's framework SQLite — which this app already uses via the default Room open-helper, so there's no new dependency — and it orders accented characters in their expected position, locale-aware.@Querytext changes; Room's schema/identity hash is unaffected.LIKE … COLLATE NOCASEsearch filter inMediaStoreSongRepository(case-insensitive matching, not sorting) is intentionally left as-is.Alternatives considered
COLLATE UNICODE— locale-independent/deterministic across locales. Happy to switch to this if preferred.Testing
Á/É/Ñnow sorts within its base-letter group rather than afterZ.