Forked from marcel-jahn/gist:65193ebce407f56cba1c6041074c8107
Created
March 12, 2018 17:26
-
-
Save HelgaZhizhka/ebcbc01f06658b3686212b19bab70a08 to your computer and use it in GitHub Desktop.
Sorting by ascending date with Underscore.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var list = [ | |
{id: 1, created_at: 'Sun Feb 22 23:19:08 +0000 2009'}, | |
{id: 2, created_at: 'Wed Jun 05 14:07:04 +0000 2013'}, | |
{id: 3, created_at: 'Wed Jun 05 10:11:30 +0000 2013'}, | |
{id: 3, created_at: 'Wed Jun 05 14:01:08 +0000 2013'} | |
]; | |
var sorted = _.sortBy(list,function(node){ | |
return - (new Date(node.created_at).getTime()); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment