var data = [{
"priority": "1",
"date": "01.03.2013",
"title": "Yeah hi"
}, {
"priority": "2",
"date": "",
"title": "Another title"
}, {
"priority": "2",
"date": "22.12.2013",
"title": "Foo"
}, {
"priority": "1",
"date": "10.04.2013",
"title": "Hey there"
}, {
"priority": "2",
"date": "15.08.2013",
"title": "Hello world"
},
...
]
I've an multidimensional array and i want to sort it in a complex way.
- First sort by "priority" - highest priority first
- Then sort all items with the same priority by "date" - the next date near today first (there are only dates in future). And if an item don't have a date put it at the end.
- Sort all items with the same date (and all with no date) by "title" - alphabetically
The first step is no problem with data.sort() but then i've no plan for doing that. How to do that?