summaryrefslogtreecommitdiff
path: root/sort/quick.hs
blob: 44efd81ac3587576e6f522f65f347e086bfc9b92 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
module Quick (
    quickSort
    ) where



quickSort :: Ord a => [a] -> [a]
quickSort [] = []
quickSort (x:xs) =
    let less = [ a | a <- xs, a < x ]
        equal = [ b | b <- (x:xs), b == x ]
        greater = [ c | c <- xs, c > x ]
    in quickSort less ++ equal ++ quickSort greater