Repository navigation
fix(table-sort): use locale-aware alphanumeric string comparison - #344
Merged
Merged
Conversation
Backport of 8a1b2af from main to the 5.0.0-rc line. Compare string values with localeCompare (numeric, case-insensitive) so e.g. 'Item 2' sorts before 'Item 10' and å/ä/ö follow the user's locale rules, treat undefined like null, and continue to the next sort key when values are equal instead of returning 0. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QHoGUgdEaYbnkn84rpkGHw
|
🎉 This PR is included in version 5.0.0-rc.21 🎉 The release is available on: Your semantic-release bot 📦🚀 |
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.
Summary
Backport of
8a1b2affrommain(shipped in 5.1.x) to the5.0.0-rcline, so users on Angular 12–15 get the same sorting behaviour without upgrading.sortOnMultipleKeysinprojects/core/src/lib/utilities/utilities.tsnow:localeCompare(…, undefined, { numeric: true, sensitivity: 'base' })— natural alphanumeric order (Item 2beforeItem 10), case-insensitive, and å/ä/ö ordered by the end user's locale rules instead of UTF-16 code units;undefinedlikenull(sorted last);continues to the next sort key when values are equal, instead of returning0(fixes multi-key tiebreaking broken since rc.20's "handle null and equal values").Behaviour is identical to
main; the only textual difference is prettier line wrapping per this branch's config. No public API changes.Before / after (ascending, single key)
sv-SEruntime locale)Örebro, Ängelholm, Åre, Alingsås, ZürichAlingsås, Zürich, Ängelholm, Åre, ÖrebroAlingsås, Zürich, Åre, Ängelholm, ÖrebroItem 10, Item 2, Item 1, Item 20Item 1, Item 10, Item 2, Item 20Item 1, Item 2, Item 10, Item 20banana, Apple, cherryApple, banana, cherryApple, banana, cherryNote: no locale is passed, so collation follows the browser's default locale (same as
main). In anenbrowser, Å/Ä/Ö are treated as accented A/O and interleave with them.Verification
npm run build(ng-packagr) succeeds.eslintandprettier --checkpass on the changed file.sortOnMultipleKeyspasses under bothen-USandsv-SEruntime locales (natural numeric order, case-insensitivity, null/undefined last, multi-key tiebreak with mixed asc/desc, numbers still numeric, Å/Ä/Ö after Z under Swedish collation).coreproject on this branch has no test target (mainmoved to vitest later), somain'sutilities.spec.tschanges could not run here.Release
Merging into
release/rctriggers the existingmain.ymlworkflow, wheresemantic-releasepublishes5.0.0-rc.21to the npmrcdist-tag (the commit is afix:).🤖 Generated with Claude Code
https://claude.ai/code/session_01QHoGUgdEaYbnkn84rpkGHw
Generated by Claude Code