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

LocaleCompare encountered inconsistent results with the browser #1852

Closed
hvppy opened this issue May 8, 2024 · 1 comment · Fixed by #1853
Closed

LocaleCompare encountered inconsistent results with the browser #1852

hvppy opened this issue May 8, 2024 · 1 comment · Fixed by #1853

Comments

@hvppy
Copy link

hvppy commented May 8, 2024

var json={
王五:3,赵六:4,张三:1,李四:2,
}

return Object.keys(json).sort(function(a,b){
return a.localeCompare(b);
});
//Browser Results ['李四', '王五', '张三', '赵六']
//jint Results ['张三', '李四', '王五', '赵六']

return Object.keys(json).sort();
//Browser Results ['张三', '李四', '王五', '赵六']
//jint Results ['张三', '李四', '王五', '赵六']

There is inconsistency in the comparison method of localeCompare, and I don't know how to solve it

@lahma
Copy link
Collaborator

lahma commented May 8, 2024

A pull request with a fix would be appreciated. I cannot read or comprehend those characters.

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 a pull request may close this issue.

2 participants