Building Your Learning Module...
Getting things ready for you!
Find videos you like?
Save to resource drawer for future reference!
Different languages have different sorting rules. Collator sorts strings according to the rules of each language - perfect for alphabetizing names, sorting lists, and comparing text.
new Intl.Collator(locale, options)collator.compare(string1, string2)Language code for sorting rules
"en-US" - English sorting"de-DE" - German sorting"sv-SE" - Swedish (ä, ö last)Control comparison behavior
sensitivity - Comparison levelnumeric - Sort "10" after "2"caseFirst - Upper/lower firstbase - Only base letters differ (a ≠ b)accent - Accents matter (a ≠ á)case - Case matters (a ≠ A)variant - All differences matter-1 if string1 comes before string20 if strings are equal1 if string1 comes after string2Sort arrays using locale-specific rules
Control how uppercase and lowercase are handled
Handle accented characters correctly
Sort strings containing numbers correctly
Compare two strings for equality or order
Find items using locale-aware comparison
Use collator.compare with Array.sort()
Each language has different sorting rules (ñ, ä, etc.)
Choose how to handle case, accents, and punctuation
Sort "file1, file2, file10" correctly with numeric: true