I have a json data similar like below. I am trying to sort it using the below code
function comp(a, b) {
return new Date(a.event_date) - new Date(b.event_date);
}
data=data.sort(comp)
But the problem is two events can be on the same dates but on different times which is another element in the json data called event_time as can be seen on the same json data.
How to sort such that firstly it sorts by event_date and if these are equal, then sorts by their respective times ?
Thanks in advance?
{
id: "xxxx",
feed_id: "yyyy",
title: "abcd ",
detail: "efgh.",
event_date: "Tue, 26 May 2015 00:00:00 +1000",
event_time: "6:30pm",
date: "Thu, 23 Apr 2015 23:05:04 +1000",
expires_at: 1432634400,
end_time: "8:00pm",
timestamp: 1429794304
},
{
id: "xxxx",
feed_id: "yyyy",
title: "efgh",
detail: "efgh.",
event_date: "Tue, 26 May 2015 00:00:00 +1000",
event_time: "4:30pm",
date: "Thu, 23 Apr 2015 23:05:04 +1000",
expires_at: 1432634400,
end_time: "8:00pm",
timestamp: 1429794304
}, {
id: "xxxx",
feed_id: "yyyy",
title: "ijkl",
detail: "efgh.",
event_date: "Tue, 27 May 2015 00:00:00 +1000",
event_time: "1:30pm",
date: "Thu, 23 Apr 2015 23:05:04 +1000",
expires_at: 1432634400,
end_time: "8:00pm",
timestamp: 1429794304
}