JSFiddle - React, Tailwind, and code Playground
by simati
JavaScript
var a = [
{
id: 1,
time: '11:1',
startDate: '2017.9.1'
},
{
id: 2,
time: '11:12',
startDate: '2017.9.1'
},
{
id: 3,
time: '11:38',
startDate: '2017.8.1'
},
{
id: 4,
time: '11:33',
startDate: '2017.8.2'
}
];
function to_date(o) {
var times = o.time.split(':');
var parts = o.startDate.split('.');
o.startDate = new Date(parts[0], parts[1] - 1, parts[2], times[0], times[1]);
return o;
}
function desc_start_time(o) {
return -o.startDate.getTime();
}
var b = _.chain(a)
.map(to_date)
.sortBy(desc_start_time)
.value();
console.log(b);