Skip to content

Instantly share code, notes, and snippets.

@jergason
Created November 23, 2014 15:28
Show Gist options
  • Save jergason/f16c19f68a9aebbe6372 to your computer and use it in GitHub Desktop.
Save jergason/f16c19f68a9aebbe6372 to your computer and use it in GitHub Desktop.
quicksort in haskell
-- see http://learnyouahaskell.com/recursion#quick-sort
quicksort' :: (Ord a) => [a] -> [a]
quicksort' [] = []
quicksort' (x:xs) =
let biggerSorted = quicksort' [a | a <- xs, a > x]
smallerSorted = quicksort' [a | a <- xs, a <= x]
in smallerSorted ++ [x] ++ biggerSorted
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment