I have an array of JavaScript objects:
var objs = [
{ key: 10, date: Thu Nov 09 2017 22:30:08 GMT+0530 },
{ key: 10, date: Thu Oct 10 2017 22:30:08 GMT+0530 },
{ key: 20, date: Thu Dec 09 2017 22:30:08 GMT+0530 }
];
AND Trying to get the results like this
var objs = [
{ key: 20, date: Thu Dec 09 2017 22:30:08 GMT+0530 },
{ key: 10, date: Thu Oct 10 2017 22:30:08 GMT+0530 },
{ key: 10, date: Thu Nov 09 2017 22:30:08 GMT+0530 }
];
Array should sort based on both key and date, Key should sort based on descending order and date should sort based on ascending order if and only if key is same.
How I can achieve this?
Here date is the Date object, so need to consider date in millisecond not as string