Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

175
Views
Intl.Collator in javascript does not sort case sensitive the same as native array sort

Why does using Intl.Collator with sensitivity option of 'case' (i.e. case sensitivity is on) result in aa coming before AA?

When using the native array.sort() the ordering is as I would expect.

const caseSensitiveCollator = new Intl.Collator('en',  { sensitivity: 'case' });

const initialData = ['AA', 'aa', 'ab', 'AB', 'ZA', 'zz'];
console.log('Before: ', initialData);

let data = initialData.concat();
data.sort(caseSensitiveCollator.compare);
console.log('After SENSITIVE', data);
// I expect ['AA', 'AB', 'ZA', 'aa', 'ab', 'zz']

data = initialData.concat().sort();
console.log('Native Array Sort', data);

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!