IntlCollator
Intl.Collator is a constructor in the ECMAScript Internationalization API that creates objects capable of comparing strings according to locale- and language-specific rules. It encapsulates locale data and options so that sorting and searching can be performed in a way that respects linguistic conventions for the selected language or region. Implementations rely on Unicode CLDR data and are available in modern web browsers and Node.js.
An Intl.Collator object provides a compare(a, b) function. The function returns a negative number if a comes
Locales and options. You create a collator with new Intl.Collator(locales, options). Locales can be a string
Example usage. const coll = new Intl.Collator('fr-FR', { numeric: true, sensitivity: 'base' }); const arr = ['2','10','1']; arr.sort(coll.compare) sorts numerically
---