Below code snippet will be useful in sorting the array of objects by its one of property. In below example, label is the property.
function sortyArrayByProperty(a, b){
var aName = a.label.toLowerCase();
var bName = b.label.toLowerCase();
return ((aName < bName) ? -1 : ((aName > bName) ? 1 : 0));
}
yourobjectsarray.sort(sortyArrayByProperty);
No comments:
Post a Comment