Skip to content

Commit

Permalink
Merge pull request mdn#1748 from hamishwillee/intl_collator
Browse files Browse the repository at this point in the history
Add options example to intl-collator
  • Loading branch information
chrisdavidmills committed Jan 18, 2021
2 parents 8365528 + acdbe8d commit f2ee02d
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions live-examples/js-examples/intl/intl-collator.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
function letterSort(lang, letters) {
letters.sort(new Intl.Collator(lang).compare);
return letters;
}
console.log(['Z', 'a', 'z', 'ä'].sort(new Intl.Collator('de').compare));
// expected output: ["a", "ä", "z", "Z"]

console.log(letterSort('de', ['a', 'z', 'ä']));
// expected output: Array ["a", "ä", "z"]
console.log(['Z', 'a', 'z', 'ä'].sort(new Intl.Collator('sv').compare));
// expected output: ["a", "z", "Z", "ä"]

console.log(letterSort('sv', ['a', 'z', 'ä']));
// expected output: Array ["a", "z", "ä"]
console.log(['Z', 'a', 'z', 'ä'].sort(new Intl.Collator('de', { caseFirst: 'upper' } ).compare));
// expected output: ["a", "ä", "Z", "z"]

0 comments on commit f2ee02d

Please sign in to comment.