-
Notifications
You must be signed in to change notification settings - Fork 29.4k
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
Sort lines correct alphabetic sorting with diacritics in Romanian #70920
Comments
On the other hand it matches up with the sorting from LibreOffice Calc. |
Sorting where? Are you talking about the explorer? |
Sort Lines Ascending in the Command Palette. |
This is actually more complicated than I thought... The reason is that different locales have different sort orders for the same characters. See a full example at https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator function letterSort(lang, letters) {
letters.sort(new Intl.Collator(lang).compare);
return letters;
}
console.log(letterSort('de', ['a','z','ä']));
// expected output: Array ["a", "ä", "z"]
console.log(letterSort('sv', ['a','z','ä']));
// expected output: Array ["a", "z", "ä"] So there is no absolute order of letters, ordering letters/strings only makes sense in a given locale. We are currently using Testing the sorting: function sort(lang, letters) {
letters.sort(new Intl.Collator(lang).compare);
return letters;
}
console.log(sort('en', ["Satu Mare", "Sălaj", "Sibiu", "Suceava"]));
// ==> ["Sălaj", "Satu Mare", "Sibiu", "Suceava"]
console.log(sort('ro', ["Satu Mare", "Sălaj", "Sibiu", "Suceava"]));
// ==> ["Satu Mare", "Sălaj", "Sibiu", "Suceava"] So under English the sort order is indeed I will change our code to instantiate a |
Issue Type: Bug
The correct order when it comes to Romanian diacritics would be a, ă, â, b, c ... i, î ... s, ș, t, ț, u, v ...
Alphabetical order - Wikipedia
But this is the result of Sort Lines Ascending on these lines:
Sălaj
should come afterSatu Mare
FWIW Sublime Text gets it worse, considering diacritics as continuing after the main latin alphabet:
Sălaj
comes afterSuceava
VS Code version: Code 1.32.3 (a3db5be, 2019-03-14T23:43:35.476Z)
OS version: Windows_NT x64 6.1.7601
The text was updated successfully, but these errors were encountered: