Skip to content

sort: read -n numbers with the locale's decimal point on the whole-line path - #16736

Open
Xnadir wants to merge 1 commit into
uutils:mainfrom
Xnadir:sort-numeric-cache-locale
Open

Xnadir wants to merge 1 commit into
uutils:mainfrom
Xnadir:sort-numeric-cache-locale

Conversation

@Xnadir

@Xnadir Xnadir commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

Fixes #16735.

With -n and no key, sort parses each whole line once as an f64 so that it can compare lines quickly. That parse always takes . as the decimal point. In de_DE, where . groups thousands, 1.000 compared as 1 instead of 1000. Lines the parse rejected, like 100,0, took the locale-aware path, so the two disagreed: sort -nu let the second 9 through, and sort -nCu accepted unsorted input.

The shortcut now runs only when the locale's decimal point is .. Other locales take the same path as -k1,1n, which already matched GNU.

The new test in test_sort.rs runs the example from the issue under LC_ALL=de_DE.UTF-8, plus a 9,5 vs 1.000 ordering case. It fails without the change and passes with it.

This change was written with the help of an AI assistant (Claude); I reviewed and tested it.

🤖 Generated with Claude Code

…ne path

With -n and no key, sort parses each line once as a float to compare
lines quickly. That parse always takes `.` as the decimal point, so in a
locale like de_DE, where `.` groups thousands, `1.000` compared as one
rather than a thousand. Lines that the parse rejected, such as `100,0`,
went the locale-aware way, so the two orders disagreed: `sort -nu` let a
duplicate through and `sort -nCu` accepted unsorted input. Only take the
shortcut when the locale's decimal point is `.`.

Fixes uutils#16735
Copilot AI balanced review requested due to automatic review settings November 20, 2026 14:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

This branch has not been deployed

No deployments
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.

sort -nu emits an exact duplicate and -nCu accepts it under de_DE.UTF-8

2 participants