A

p

e

r

s

o

n

a

l

B

l

o

g

Booyah!

quicksort :: (Ord a) => [a] -> [a]
quicksort [] = []
quicksort (x:xs) = smallerSorted ++ [x] ++ biggerSorted
  where
    smallerSorted = quicksort [ a | a <- xs, a <= x ]
    biggerSorted = quicksort [ a | a <- xs, a > x ]

main = do
  putStr (show list ++ " using quicksort: ")
  putStrLn (show (quicksort list))
    where list = [ 5, 3, 2, 4, 1, 0 ]

http://learnyouahaskell.com/