I am using Coffescript, underscore.js, knockout, and I am trying to sort an array by date, but for some reason its not working
let accounts = [
{
id: 101,
content: "abc1",
createdDate: "2015-12-22T00:00:00"
},
{
id: 102,
content: "abc2",
createdDate: "2012-12-22T00:00:00"
}
]
This is how I wrote the code in coffeescript
_.sortBy(accounts, (a) -> a.createdDate)
The same generated code in JS
return this.accounts(_.sortBy(accounts, function(a) {
return a.createdDate;
}));
Please let me know where I am going wrong. I am not getting any error, but the array is not getting sorted by date.