Last active
February 26, 2018 21:16
-
-
Save adamculpepper/51137d2eb00a2d499681f5d520101e9b to your computer and use it in GitHub Desktop.
JavaScript: Simple Numeric Array Sort
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
var array = [11, 10, 1111, 22, 1, 1, 1, 2, 2, 3, 4, 4, 5, 5, 5]; | |
function sortArray(input) { | |
var output = input.sort(function(a, b) { | |
return a - b; | |
}); | |
return output; | |
} | |
$("#output").text(sortArray(array)); // 1,1,1,2,2,3,4,4,5,5,5,10,11,22,1111 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment