JavaScript Intl.Collator() constructor is used to create an Intl.Collator object.
Syntax
new Intl.Collator(locales,option)
or
Intl.Collator(locales,option)
You can call the constructor with or without a new keyword.
Parameters
locales: A string or array of strings that represent the BCP 47 language tags.
options: It is an object that has many properties like localeMatcher, usage, numeric, sensitivity, caseFirst, etc.
Return Value
It returns an Intl.Collator object.
Example 1: How to Use JavaScript Intl Collator() Constructor
const footballer = new Intl.Collator('en-US', { sensitivity: 'base' });
console.log(footballer.compare('ronaldo', 'RONALDO'));
console.log(footballer.compare('ronaldo', 'MESSI'));
console.log(footballer.compare('5', '7'));
console.log(footballer.compare('true', 'false'));
Output
0
1
-1
1
Example 2: Sorting with Uppercase and Lowercase
console.log(['ronaldo','MESSI','MBAPPE','mbappe','RONALDO','messi']
.sort(new Intl.Collator('en-US', {caseFirst:'upper'}).compare));
console.log(['ronaldo','MESSI','MBAPPE','mbappe','RONALDO','messi']
.sort(new Intl.Collator('en-US', {caseFirst:'lower'}).compare));
Output
[ 'MBAPPE', 'mbappe', 'MESSI', 'messi', 'RONALDO', 'ronaldo' ]
[ 'mbappe', 'MBAPPE', 'messi', 'MESSI', 'ronaldo', 'RONALDO' ]
JavaScript Intl Collator Methods
JavaScript Intl Collator compare()
JavaScript Intl Collator resolvedOptions()
JavaScript Intl Collator supportedLocalesOf()
Browser Compatibility
Chrome 24+ | Edge 12+ | Firefox 29+ | Safari 10+ | Opera 15+ |
Yes | Yes | Yes | Yes | Yes |
That’s it!

Krunal Lathiya is a seasoned Computer Science expert with over eight years in the tech industry. He boasts deep knowledge in Data Science and Machine Learning. Versed in Python, JavaScript, PHP, R, and Golang. Skilled in frameworks like Angular and React and platforms such as Node.js. His expertise spans both front-end and back-end development. His proficiency in the Python language stands as a testament to his versatility and commitment to the craft.