Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Sort JSON via javascript on multiple properties
/* --- 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
You can’t perform that action at this time.