JSFiddle - React, Tailwind, and code Playground
by Satpal Singh
JavaScript
var trArr = [{
name: 'Abc',
id: 1
}, {
name: 'ACd',
id: 3
}, {
name: 'Aab',
id: 4
}];
function compare(a, b) {
if (a.name.toLowerCase() < b.name.toLowerCase()) {
return -1;
}
if (a.name.toLowerCase() > b.name.toLowerCase()) {
return 1;
}
return 0;
}
trArr.sort(compare);
console.log(trArr)