qsort [] = []
qsort (p:xs) = qsort lt ++ [p] ++ qsort gt
where (lt, gt) = partition ((>) p) xs
partition1 _ [] = ([], [])
partition1 f (x:xs) =
let (ys, zs) = partition1 f xs
in if f x
then (x:ys, zs)
else (ys, x:zs)
partition _ [] = ([], [])
partition f (x:xs)
| f x = (x:ys, zs)
| otherwise = (ys, x:zs)
where (ys, zs) = partition f xs
main = do
let li = [5,1,4,2,3]
putStrLn $ show $ qsort li
To embed this project on your website, copy the following code and paste it into your website's HTML: