Skip to content

Instantly share code, notes, and snippets.

@bennetthardwick
Created April 25, 2018 07:51
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 bennetthardwick/438a8a3b9960438d98b43a75921ddef4 to your computer and use it in GitHub Desktop.
Save bennetthardwick/438a8a3b9960438d98b43a75921ddef4 to your computer and use it in GitHub Desktop.
An awesome version of Haskell's quick-sort, done in JavaScript.
const quicksort = (arr) => {
return (arr.length <= 0) ? [] : (() => {
let h = arr.shift();
return quicksort(arr.filter(a => h >= a)).concat([h]).concat(quicksort(arr.filter(a => h < a)));
})();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment