Created
October 6, 2015 07:56
-
-
Save stryju/3b6c260a122402023a44 to your computer and use it in GitHub Desktop.
quicksort (haskell-inspired) in es6
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
function quicksort([ x, ...xs ]) { | |
if (!arguments[0].length) return []; | |
return [ ...xs.filter( y => y <= x ), x, ...xs.filter( y => y > x ) ]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment