Created
January 24, 2012 07:09
-
-
Save justinpeterman/1668647 to your computer and use it in GitHub Desktop.
sort an array of objects based on a particular obj property
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
function compare(a,b) { | |
if (a.PARAM1 < b.PARAM2) | |
return -1; | |
if (a.PARAM1 > b.PARAM2) | |
return 1; | |
return 0; | |
} | |
ARRAY_OBJECTS.sort(compare); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment