Skip to content

Instantly share code, notes, and snippets.

@arr-ee
Created February 14, 2014 05:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arr-ee/8996177 to your computer and use it in GitHub Desktop.
Save arr-ee/8996177 to your computer and use it in GitHub Desktop.
Javascript is awesome at sorting stuff.
> a
[ 'Wed Dec 11 2013 04:00:00 GMT+0400 (MSK)',
'Tue Dec 10 2013 04:00:00 GMT+0400 (MSK)',
'Sun Dec 15 2013 04:00:00 GMT+0400 (MSK)',
'Sat Dec 14 2013 04:00:00 GMT+0400 (MSK)' ]
> a.map(function(d){return new Date(d)}).sort()
[ Sat Dec 14 2013 04:00:00 GMT+0400 (MSK),
Sun Dec 15 2013 04:00:00 GMT+0400 (MSK),
Tue Dec 10 2013 04:00:00 GMT+0400 (MSK),
Wed Dec 11 2013 04:00:00 GMT+0400 (MSK) ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment