Skip to content

Instantly share code, notes, and snippets.

@orrisroot
Created October 9, 2025 09:37
Show Gist options
  • Select an option

  • Save orrisroot/1015ef6b0ddadac2d2ec1f2acb43f7b8 to your computer and use it in GitHub Desktop.

Select an option

Save orrisroot/1015ef6b0ddadac2d2ec1f2acb43f7b8 to your computer and use it in GitHub Desktop.
const naturalCompare = (a: string, b: string): number => {
const locales = new Set<string>([...navigator.languages, 'en-US', 'ja-JP']);
return new Intl.Collator(Array.from(locales), {
sensitivity: 'variant',
numeric: true,
}).compare(a, b);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment