So when I try to sort alphabets with just sort, it works as expected like:
['a', 'A'].sort().join('') // 'Aa'
However, when I use localeCompare with sort, it doesn't work as expected:
['a', 'A'].sort((a, b) => a.localeCompare(b)).join('') // 'aA'
OR
['a', 'b', 'A', 'c', 'b', 'A', 'B'].sort((a, b) => a.localeCompare(b)).join('')
// 'aAAbbBc'
Why doesn't the sort place uppercase letters like 'A' before lowercase case letters as would have happened when using just sort() with no arguments ? I'm trying to sort the letters in ascending order (lexicographically).Thanks!