I'm trying to sort array of strings ['d', 'CC', 'BB', 'b', 'a', 'Am','AMG']
in such order ["AMG", "Am", "a", "BB", "b", "CC", "d"]
Using
arr.sort(function (a, b) {
return a.toLowerCase().localeCompare(b.toLowerCase());
});
I get ["a", "Am", "AMG", "b", "BB", "CC", "d"]
acomes before the entry forama<Aand you wanta>A