I just went through lodash doc, and perhaps you could try sortBy
Try it: http://jsfiddle.net/3Wza8/
var myObjects = [
{ id: '1', username: 'bill.jones', active: true, createdon: new Date('03/29/2014') },
{ id: '2', username: 'woohoo', active: true, createdon: new Date('03/28/2014') },
{ id: '3', username: 'someuser', active: true, createdon: new Date('03/30/2014') }
];
myObjects = _.sortBy(myObjects, 'createdon');
_.forEach(myObjects, function (result) {
console.log(result);
});
EDIT: as Cookie Monster pointed out, it's important that your createdon
field is a Date, and not a string.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…