Skip to content

Instantly share code, notes, and snippets.

@higuoxing
Last active January 10, 2018 05:23
Show Gist options
  • Save higuoxing/9d6a8e9818bb72505aca422370f7fe14 to your computer and use it in GitHub Desktop.
Save higuoxing/9d6a8e9818bb72505aca422370f7fe14 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 (filter (<= x) xs)
biggerSorted = quicksort (filter (> x) xs)
in smallerSorted ++ [x] ++ biggerSorted
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment