Created
April 13, 2021 13:10
-
-
Save shoaibmehedi7/8020c8d80c32125c52fd2aabea3ad6e1 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
// sort alphabetically | |
const name = ['Shoaib', 'Mehedi', 'Alex', 'Jane']; | |
const arr = [1, 30, 4, 21, 100000]; | |
name.sort(); | |
console.log(name); | |
// sort numerically | |
arr.sort(function(a, b) { | |
return a - b; | |
}); | |
console.log(arr); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment