Skip to content

perf: reuse the natural sort collator - #53

Merged
thetutlage merged 1 commit into
poppinss:7.xfrom
RomainForks:perf/natural-sort-collator
Sep 5, 2026
Merged

perf: reuse the natural sort collator#53
thetutlage merged 1 commit into
poppinss:7.xfrom
RomainForks:perf/natural-sort-collator

Conversation

@RomainLanz

Copy link
Copy Markdown
Member

Hey! 👋🏻

naturalSort calls localeCompare with options on every comparison, which repeats collator setup during sorting.

This reuses a single Intl.Collator, created on the first comparison so imports don't pay the initialization cost. It keeps the default locale and the same options: numeric: true and sensitivity: 'base'.

Tests cover ordering against the previous implementation and numeric path sorting through fsReadAll.

Build, lint, typecheck and all 182 tests pass on Node 26.5.1.

@thetutlage
thetutlage merged commit 099b259 into poppinss:7.x Sep 5, 2026
6 checks passed
@RomainLanz
RomainLanz deleted the perf/natural-sort-collator branch September 5, 2026 10:48
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.

2 participants