Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

String.prototype.localeCompare sorting incorrectly with numeric #8392

Closed
trs opened this issue Nov 15, 2020 · 1 comment
Closed

String.prototype.localeCompare sorting incorrectly with numeric #8392

trs opened this issue Nov 15, 2020 · 1 comment

Comments

@trs
Copy link

trs commented Nov 15, 2020

It seems that String.prototype.localeCompare does not correctly take into account the numeric option when sorting.

Example snippet:

const items = ['1', '2', '1a', '10b', '10a', '10'];
const sortedItems = items.sort((a, b) => a.localeCompare(b, 'en', {numeric: true}));
console.log(sortedItems);

Node and the browser log out [ '1', '1a', '2', '10', '10a', '10b' ].
Whereas Deno logs out [ "1", "10", "10a", "10b", "1a", "2" ].

Deno Repl
Node Repl

@trs
Copy link
Author

trs commented Nov 15, 2020

Sorry this seems to be a duplicate of #1968

@trs trs closed this as completed Nov 15, 2020
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

No branches or pull requests

1 participant