Skip to content

Let natural sort order be runtime and locale independent to close #820 - #837

Merged
mathiasrw merged 3 commits into
mainfrom
fix/820
Oct 23, 2026
Merged

mathiasrw merged 3 commits into
mainfrom
fix/820

Conversation

@mathiasrw

@mathiasrw mathiasrw commented Oct 23, 2026 •

Copy link
Copy Markdown
Owner

Closes #820

Stacked on #836.

Change

The default order, natural, is now the same everywhere:

  • Names that natural sees as the same are ordered by ascii, as the help says. Before, they kept the order of the glob, which differs between Node and Bun.
  • The locale is fixed to en. Before, Node followed the locale of the user and Bun did not.

file1.md file01.md file001.md z.md aa.md cafe.md café.md, with --sort natural:

Order
Bun, before aa cafe café file1 file01 file001 z
Node with LC_ALL=da_DK.UTF-8, before cafe café file001 file01 file1 z aa
Bun, Node, and Node with da_DK, now aa cafe café file001 file01 file1 z

It matters most with --rename and $n, as the numbers follow the order.

Tests

test/fix/820.test.js is new and checks the ties. The locale can not be changed inside the test, so it was checked by hand with Node, as in the table. yarn test-ci passes.

From the review of 23 October.

After the review of 24 October

  • The test runs with --sort natural, so the files are handled one at a time and printed in the order of the sort. Without it the order the files finish in could make the test flaky.

Follow-up

  • test/fix/820.test.js covers numbers, case, accents, aa and --sort-reverse, next to the names it sees as the same.
  • test/cli/run.sh sorts b.file and aab.file with LC_ALL=da_DK.UTF-8 on Node and Bun. In Danish aa sorts after z, so Node gave b.file first before the fix.

@mathiasrw
mathiasrw marked this pull request as draft October 23, 2026 13:05
@mathiasrw
mathiasrw marked this pull request as ready for review October 23, 2026 13:24
@mathiasrw
mathiasrw added this pull request to stack #841 October 23, 2026 13:56
@mathiasrw mathiasrw changed the title Make the natural order the same on Node and Bun, and in every locale to close #820 Let natural sort order be runtime and locale independent to close #820 Oct 23, 2026
@mathiasrw
mathiasrw marked this pull request as draft October 23, 2026 15:30
@mathiasrw
mathiasrw marked this pull request as ready for review October 23, 2026 15:37
@mathiasrw
mathiasrw removed this pull request from stack #841 October 23, 2026 15:57
@mathiasrw
mathiasrw added this pull request to stack #849 October 23, 2026 16:12
@mathiasrw
mathiasrw removed this pull request from stack #849 October 23, 2026 16:12
@mathiasrw
mathiasrw added this pull request to stack #850 October 23, 2026 16:17
@mathiasrw
mathiasrw removed this pull request from stack #850 October 23, 2026 16:47
@mathiasrw
mathiasrw added this pull request to stack #853 October 23, 2026 16:51
@mathiasrw
mathiasrw force-pushed the fix/820 branch 4 times, most recently from f41864a to cbc9e28 Compare October 23, 2026 17:02
Base automatically changed from fix/819 to main October 23, 2026 17:02
@mathiasrw
mathiasrw merged commit 56e174e into main Oct 23, 2026
6 of 7 checks passed
@mathiasrw
mathiasrw deleted the fix/820 branch October 23, 2026 17:12
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.

Fix the natural order differing between Node and Bun

1 participant