Skip to content

Instantly share code, notes, and snippets.

@wojtekmach
Created October 3, 2013 19:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wojtekmach/6815328 to your computer and use it in GitHub Desktop.
Save wojtekmach/6815328 to your computer and use it in GitHub Desktop.
quicksort :: (Ord a) => [a] -> [a]
quicksort [] = []
quicksort (x:xs) =
let smaller = quicksort $ filter (<=x) xs
bigger = quicksort $ filter (>x) xs
in smaller ++ [x] ++ bigger
main = do
putStrLn $ show $ quicksort [1, 4, 2, 3]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment