Skip to content

Instantly share code, notes, and snippets.

@ClausPolanka
Created October 15, 2010 13:43
Show Gist options
  • Save ClausPolanka/628201 to your computer and use it in GitHub Desktop.
Save ClausPolanka/628201 to your computer and use it in GitHub Desktop.
Quicksort via filters 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