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

JSON sort: use localeCompare instead of ASCII sort #255

Merged
merged 2 commits into from
Dec 11, 2024
Merged

Conversation

aiday-mar
Copy link
Contributor

@aiday-mar aiday-mar commented Dec 10, 2024

@aiday-mar aiday-mar self-assigned this Dec 10, 2024
@aiday-mar aiday-mar requested a review from aeschli December 10, 2024 12:01
@aiday-mar aiday-mar marked this pull request as ready for review December 10, 2024 12:01
@aiday-mar aiday-mar enabled auto-merge December 10, 2024 12:02
@vs-code-engineering vs-code-engineering bot added this to the February 2025 milestone Dec 10, 2024
@aeschli
Copy link
Contributor

aeschli commented Dec 10, 2024

@aiday-mar I think the correct approach is to use localeCompare. Every locale has different sorting rules.

> i = [ 'a0', '[a0]', 'A1', 'B', 'b' ]
[ 'a0', '[a0]', 'A1', 'B', 'b' ]
> i.sort((a, b) => a.localeCompare(b))
[ '[a0]', 'a0', 'A1', 'b', 'B' ]
> 

@aiday-mar
Copy link
Contributor Author

aiday-mar commented Dec 11, 2024

Hi @aeschli thanks for the review, I was not aware of this method. I will change that right now

@aiday-mar
Copy link
Contributor Author

I made the change

@aiday-mar aiday-mar changed the title JSON sort: sort symbols first, then lower case, then upper case JSON sort: use localeCompare instead of ASCII sort Dec 11, 2024
@aiday-mar aiday-mar merged commit 3d95996 into main Dec 11, 2024
3 checks passed
@aiday-mar aiday-mar deleted the awful-ptarmigan branch December 11, 2024 12:19
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.

Incorrect JSON sort order
2 participants