JSFiddle - React, Tailwind, and code Playground
by mmansion
HTML
<script src="http://documentcloud.github.com/underscore/underscore-min.js"></script>
JavaScript
var a = [
{
id: 1,
startDate: '04-11-13 203000'
},
{
id: 2,
startDate: '04-11-13 220100'
},
{
id: 3,
startDate: '04-11-13 163000'
},
{
id: 4,
startDate: '04-11-13 200000'
}
];
function to_date(o) {
var parts = o.startDate.split('-');
o.startDate = new Date(parts[0], parts[1] - 1, parts[2]);
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);