Created
August 17, 2016 17:14
-
-
Save aug2uag/f75300ffd476b29d12c37d897a9ba583 to your computer and use it in GitHub Desktop.
timestamp sort 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 o = [ | |
{created:1356036198452 , val:'1356036198452 '}, | |
{created:1356039026690, val:'1356039026690'}, | |
{created:1356039067568, val:'1356039067568'}, | |
{created:1356035166411, val:'1356035166411'} | |
] | |
function newestToOldest(a,b) { | |
if (a.created < b.created) | |
return 1; | |
if (a.created > b.created) | |
return -1; | |
return 0; | |
}; | |
o.sort(newestToOldest); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment