I got an array (see below for one object in the array) that I need to sort by firstname using JavaScript. How can I do it?
var user = { bio: null, emai
also for both asec and desc sort, u can use this : suppose we have a variable SortType that specify ascending sort or descending sort you want:
users.sort(function(a,b){ return sortType==="asc"? a.firstName.localeCompare( b.firstName): -( a.firstName.localeCompare( b.firstName)); })