Skip to content

Instantly share code, notes, and snippets.

@shigemk2
Created January 21, 2015 12:16
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 shigemk2/6acd5ad8c20a71f0e9c1 to your computer and use it in GitHub Desktop.
Save shigemk2/6acd5ad8c20a71f0e9c1 to your computer and use it in GitHub Desktop.
quicksort :: (Ord a) => [a] -> [a]
quicksort [] = []
quicksort (x:xs) =
let smallerOrEqual = filter (<= x) xs
larger = filter (> x) xs
in quicksort smallerOrEqual ++ [x] ++ quicksort larger
main = do
print $ quicksort [4,3,2,1,0,6,9,8,7,10]
print $ quicksort $ filter (> 5) [4,3,2,1,0,6,9,8,7,10]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment