JavaScript Intl Collator() Constructor Last Updated : 04 Apr, 2023 Summarize Comments Improve Suggest changes Share Like Article Like Report JavaScript Intl.Collator() constructor is used to create an Intl.Collator object. This constructor can be called with or without the new keyword. Syntax: new Intl.Collator(loc, opt) Parameters: This constructor takes two parameters and both are optional. loc: This is a String or an array of Strings with the following values allowed:co: Specifies the variation collants to be usedkn: Specifies the numeric collations to be usedkf: Specifies whether uppercase or lowercase sorting should be used.opt: It is an object which has some properties like localeMatcher, usage, caseFirst etc. Returns: An Intl.Collator object. Below examples illustrate the JavaScript Intl Collator() Constructor: Example 1: This example implements the basic Collator constructor and uses its compare method JavaScript console.log(new Intl.Collator().compare('b', 's')); console.log(new Intl.Collator().compare(4, 2)); console.log(new Intl.Collator().compare(true, true)); Output: -1 1 0 Example 2: This example performs a modified sorting by using the Intl constructor JavaScript console.log(['a','A','b','B'] .sort(new Intl.Collator("en", {caseFirst:"upper"}).compare)); console.log(['a','A','b','B'] .sort(new Intl.Collator("en", {caseFirst:"lower"}).compare)); Output: (4) ['A', 'a', 'B', 'b'] (4) ['a', 'A', 'b', 'B'] Supported Browsers: ChromeEdgeFirefoxOperaSafari We have a complete list of JavaScript Intl methods to check those please go through, the JavaScript Intl Reference article. Comment More infoAdvertise with us Next Article JavaScript Intl Segementer() Constructor S shobhit_sharma Follow Improve Article Tags : JavaScript Web Technologies Similar Reads JavaScript Intl ListFormat() Constructor JavaScript Intl.ListFormat() Constructor is used for creating Intl.ListFormat object. This constructor is created using the new keyword. If we create the constructor without the new keyword it will give a TypeError. Syntax: new Intl.ListFormat(loc, opt) Parameters: It has two parameters both are opt 2 min read JavaScript Intl Segementer() Constructor JavaScript Intl Segmenter() Constructor is used for creating Intl.Segmenter object. This constructor is created using the new keyword. If we create the constructor without the new keyword it will give a TypeError. Syntax: new Intl.Segmenter(loc, opt) Parameters: It has two parameters both are option 2 min read JavaScript Intl PluralRules() Constructor JavaScript Intl PluralRules() Constructor is used for creating Intl.PluralRules object. This constructor is created using the new keyword. If we create the constructor without the new keyword it will give a TypeError. Syntax: new Intl.PluralRules(loc, opt) Parameters: loc: It is a String or an array 1 min read PHP | Collator __construct() Function The Collator::__construct() function is an inbuilt function in PHP which is used to create a new instance of Collator. Syntax: public Collator::__construct( string $locale ) Parameters: This function accepts single parameter $locale which holds the collation rules. If a null value is passed for the 1 min read JavaScript Intl Collator resolvedOptions() Method The Intl.Collator.prototype.resolvedOptions() method is an inbuilt method in JavaScript that is used to return a new object with properties reflecting the locale and collation options computed during the initialization of this Collator object.Syntax:Â collator.resolvedOptions() Parameters: This func 1 min read PHP | Collator create() Function The Collator::create() function is an inbuilt function in PHP which is used to create a new collector. Syntax: Object oriented style: Collator Collator::create( $locale ) Procedural style: Collator collator_create( $locale ) Parameters: This function accepts single parameter $locale which holds the 1 min read Like