Created
May 4, 2013 17:22
-
-
Save 40/5518151 to your computer and use it in GitHub Desktop.
sort an array in javascript
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 numberArray = [40, 1, 5, 200]; | |
function compareNumbers(a, b) { | |
return a - b; | |
} | |
document.getElementById("sorted").innerHTML =numberArray.sort(compareNumbers); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment