Sort arrays - 2 toLowerCase
JavaScript
var sortme = function (names) {
return names.sort(function (a, b) {
if (a.charAt(0).toLowerCase() > b.charAt(0).toLowerCase()) return 1;
if (a.charAt(0).toLowerCase() < b.charAt(0).toLowerCase()) return -1;
return 0;
});
}
/*
sortme = function( names ){
return names.sort(function(a,b){
return a.toLowerCase().localeCompare(b.toLowerCase())
});
}
*/
var names = ["Hello", "there", "I'm", "fine"];
console.log(sortme(names));