Need help sorting json data by two fields, prioritizing field value and then date.
Check out this demo
Json input
[{
"title" : "Title 2",
"pin" : false,
"date" : 20130411204207
},{
"title" : "Title 3",
"date" : 20140411204207
},{
"title" : "Title 4",
"date" : 20120411204207
},{
"title" : "Title 1",
"pin" : true,
"date" : 20100411204207
}]
I aim to prioritize objects with "pin : true" first, followed by descending order of "date". Using "orderBy" method, any alternatives?
http://jsfiddle.net/tomalex0/tvLUK/1/
Output json
[
{
"title": "Title 1",
"pin": true,
"date": 20100411204207
},
{
"title": "Title 3",
"date": 20140411204207
},
{
"title": "Title 2",
"pin": false,
"date": 20130411204207
},
{
"title": "Title 4",
"date": 20120411204207
}
]