Last active
September 1, 2017 09:42
-
-
Save cemerson/f1f1434286c1262b403f3d85c96688e0 to your computer and use it in GitHub Desktop.
Sort JSON via javascript on multiple properties
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
/* --- How to sort JSON data (javascript object) via multiple properties --- */ | |
/* Solution: | |
// --> https://stackoverflow.com/a/32494726/826308 */ | |
/* My usage: */ | |
myData = sortByAttribute(myData, 'group_index', 'order_override', 'name'); | |
/* My (example) data */ | |
var myData = [ | |
{ | |
order_override:0, | |
group_index:1, | |
name:"Item1", | |
location:"City1, State1", | |
phone:"123-123-1234" | |
}, | |
{ | |
order_override:0, | |
group_index:2, | |
name:"Item2", | |
location:"City2, State2", | |
phone:"456-456-4567" | |
}, ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment