Last active
September 3, 2019 22:59
-
-
Save masautt/fe73908d0ccdde9a3e6df98ea884f108 to your computer and use it in GitHub Desktop.
How to sort array in JavaScript?
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 arr = ["7", "2", "5", "9"]; | |
// Sort in ascending order? | |
arr.sort(); // --> 2,5,7,9 | |
// Descending order? | |
arr.reverse(); // --> 9,7,5,2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment