Created
April 25, 2018 07:51
-
-
Save bennetthardwick/438a8a3b9960438d98b43a75921ddef4 to your computer and use it in GitHub Desktop.
An awesome version of Haskell's quick-sort, done in JavaScript.
This file contains 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 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