Skip to content

Instantly share code, notes, and snippets.

@fliptheweb
Last active October 14, 2016 07:25
Show Gist options
  • Save fliptheweb/d23144d2354dcc9bbcc6b13ab5044a2e to your computer and use it in GitHub Desktop.
Save fliptheweb/d23144d2354dcc9bbcc6b13ab5044a2e to your computer and use it in GitHub Desktop.
Classic Haskell quicksort to js es6 implementation with destructuring and rest/spread operator
quickSort = ([x, ...xs]) => {
if (typeof(x) === 'undefined') return [];
return [
...quickSort(xs.filter(y => y <= x)),
x,
...quickSort(xs.filter(y => y > x))
];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment