Created
June 4, 2015 15:04
-
-
Save jasdeepkhalsa/2b7d90b3fcc38236b0b3 to your computer and use it in GitHub Desktop.
Sort an array of objects
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// From: http://stackoverflow.com/questions/1129216/sort-array-of-objects-by-property-value-in-javascript | |
function compare(a,b) { | |
if (a.last_nom < b.last_nom) | |
return -1; | |
if (a.last_nom > b.last_nom) | |
return 1; | |
return 0; | |
} | |
objs.sort(compare); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment