Created
February 11, 2019 19:09
-
-
Save hadpro24/12ee3218268c6a356199f2d73a156b66 to your computer and use it in GitHub Desktop.
ThoroughLoudBytecode created by hadpro24 - https://repl.it/@hadpro24/ThoroughLoudBytecode
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
const allStates = ["Abia", "Adamawa", "Anambra", "Akwa Ibom", "Bauchi", "Bayelsa", "Benue", "Borno", "Cross River", "Delta", "Ebonyi", "Enugu", "Edo", "Ekiti", "Gombe", "Imo", "Jigawa", "Kaduna", "Kano", "Katsina", "Kebbi", "Kogi", "Kwara", "Lagos", "Nasarawa", "Niger", "Ogun", "Ondo", "Osun", "Oyo", "Plateau", "Rivers", "Sokoto", "Taraba", "Yobe", "Zamfara"]; | |
function compare(x, y) { | |
return x.length - y.length; | |
} | |
const sortByNameLength = (states) => { | |
states.sort(compare); | |
return states; | |
} | |
const sorted = sortByNameLength(allStates); | |
console.log(sorted); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Andela Sort, for testing