fork download
  1. -- quick sort
  2. sort :: Ord a => [a] -> [a]
  3. sort [] = []
  4. sort (h:t) = sort [a | a <- t, a <= h] ++ [h] ++ sort [b | b <- t, b > h]
  5.  
  6. main :: IO ()
  7. main = print (sort [7,2,4,9,1,5,4,8])
  8.  
  9.  
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
[1,2,4,4,5,7,8,9]