Skip to content

Instantly share code, notes, and snippets.

@icesernia
Created March 8, 2021 16:34
Show Gist options
  • Save icesernia/e51610ce125b960bdf1d1369a072250d to your computer and use it in GitHub Desktop.
Save icesernia/e51610ce125b960bdf1d1369a072250d to your computer and use it in GitHub Desktop.
function letterSort(lang, letters) {
letters.sort(new Intl.Collator(lang).compare);
return letters;
}
console.log(letterSort('th', ['a','ฮ', 'z', 'ก'])); // expected output: ["ก", "ฮ", "a", "z"]
console.log(letterSort('en', ['a','ฮ', 'z', 'ก'])); // expected output: ["a", "z", "ก", "ฮ"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment