Skip to content

Instantly share code, notes, and snippets.

@jslnriot
Created April 10, 2016 14:38
Show Gist options
  • Save jslnriot/3ee5f03aab5434ca50e41da2e586bdd3 to your computer and use it in GitHub Desktop.
Save jslnriot/3ee5f03aab5434ca50e41da2e586bdd3 to your computer and use it in GitHub Desktop.
numArr = [1,2,4,5,3,6,10,11,5,20,50,33,29];
sortAscending = numArr.sort(function(a,b) {
return a - b;
});
console.log(sortAscending);
sortDescending = numArr.sort(function(a,b){
return b - a;
});
console.log(sortDescending);
wordArr = ["orange", "apple", "grape"];
sortWordAscending = wordArr.sort();
console.log(sortWordAscending);
sortWordDescending = wordArr.reverse();
console.log(sortWordDescending);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment