Skip to content

Instantly share code, notes, and snippets.

@gdejohn
Last active August 29, 2015 14:21
Show Gist options
  • Save gdejohn/696ea85f806b2b43528f to your computer and use it in GitHub Desktop.
Save gdejohn/696ea85f806b2b43528f to your computer and use it in GitHub Desktop.
Element[] quicksort<Element>({Element*} elements)
given Element satisfies Comparable<Element> =>
if (exists first = elements.first)
then [first.largerThan, first.notLargerThan]
.map(compose(quicksort<Element>, elements.rest.filter))
.interpose([first])
.reduce(concatenate<Element>)
else [];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment