Skip to content

Instantly share code, notes, and snippets.

@pwxcoo
Created December 2, 2018 04:04
Show Gist options
  • Save pwxcoo/955d67a6a60d6a2fbdd72b0b1d7b9aed to your computer and use it in GitHub Desktop.
Save pwxcoo/955d67a6a60d6a2fbdd72b0b1d7b9aed to your computer and use it in GitHub Desktop.
quick sort in Haskell
quicksort :: (Ord a) => [a] -> [a]
quicksort [] = []
quicksort (x:xs) =
let smallerSorted = quicksort [a | a <- xs, a <= x]
biggerSorted = 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