Skip to content

Instantly share code, notes, and snippets.

@hadpro24
Created February 11, 2019 19:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hadpro24/12ee3218268c6a356199f2d73a156b66 to your computer and use it in GitHub Desktop.
Save hadpro24/12ee3218268c6a356199f2d73a156b66 to your computer and use it in GitHub Desktop.
ThoroughLoudBytecode created by hadpro24 - https://repl.it/@hadpro24/ThoroughLoudBytecode
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);
@hadpro24
Copy link
Author

Andela Sort, for testing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment