1//Sort object by v1 property alphabetically (case insensitive)
2let objArray= [
3 {v1:"Bee", v2: 2},
4 {v1:"Apple", v2: 8},
5 {v1:"bat", v2: 4},
6];
7let sortedArray= objArray.sort(function(a, b) {
8 return a.v1.localeCompare(b.v1);
9}); // [{v1: "Apple", v2: 8}, {v1: "bat", v2: 2}, {v1: "Bee", v2: 2}]
1objArray.sort(function(a, b) {
2 var textA = a.DepartmentName.toUpperCase();
3 var textB = b.DepartmentName.toUpperCase();
4 return (textA < textB) ? -1 : (textA > textB) ? 1 : 0;
5});
6