Created
July 27, 2011 03:24
-
-
Save DavidQL/1108606 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
(function() { | |
var sorted_array = [1,22,13,4,5].sort(function(a, b) { | |
// you get a and b to sort. | |
// if the function returns a.. | |
// negative number: a comes ahead in sort order | |
// a positive number: b comes first | |
return a-b; | |
}); | |
console.log(sorted_array); | |
// returns [1, 13, 22, 4, 5] | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment