Repository navigation
Respect secondary digit grouping in locale-aware sorting - #210
Closed
KennyMcSimpson wants to merge 1 commit into
Closed
KennyMcSimpson wants to merge 1 commit into
KennyMcSimpson wants to merge 1 commit into
Conversation
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.
Under
en_IN.UTF-8, locale-aware sorting currently puts1,00,000before20,000. The locale uses a three-digit rightmost group and two-digit secondary groups ([3, 2, 0]), but the thousands-separator regex only recognizes three-digit groups. It leaves part of the punctuation in the numeric key.Read the primary and secondary grouping sizes from the standard-library or ICU backend and recognize secondary groups followed by another separator. Keep the existing three-digit grouping behavior and decimal guards. The lookahead stays bounded rather than scanning the remaining grouped number for every separator.
Tests cover integer/float sorting through
LOCALENUMandLOCALE, strings containing grouped numbers, signs/exponents, compatibility with three-digit groups, and metadata fallbacks in both locale backends. The realen_INintegration cases skip only when that locale is unavailable; the transform and backend cases are portable.Validation on Windows:
natsort.py:695in both versions.Native PyICU could not be installed in this Windows environment, so its new metadata paths were checked with stubs rather than a native ICU run. The APIs were also checked in the official PyICU 1.0 and 2.17 sources. The repository's existing Ubuntu extras job covers native ICU when CI runs.
AI assistance: prepared with OpenAI Codex. The checks above were run locally; this does not claim human review or successful upstream CI.