I have an array of objects with two keys:
- Score
- Date
I need to sort the array in reverse order, from highest to lowest. I have this code to sort the array by score:
highscores.sort(function(a, b) {
return b.score - a.score;
});
I'd like to sort it by date also if the score values are equals, i.e.
Array = [
{score: 200, date: 11/11/2016},
{score: 300, date: 11/11/2016},
{score: 200, date: 12/11/2016}
];
I expect this result:
Array = [
{score: 300, date: 11/11/2016},
{score: 200, date: 12/11/2016},
{score: 200, date: 11/11/2016}
];