fork download
  1. import Data.List (partition)
  2.  
  3. quicksort :: Ord a => [a] -> [a]
  4. quicksort [] = []
  5. quicksort [x] = [x]
  6. quicksort (pivot : rest) =
  7. let (smaller, notSmaller) = partition (< pivot) rest
  8. in quicksort smaller ++ pivot : quicksort notSmaller
  9.  
  10. main = print (quicksort [6,8,0,54,568,2,17,68,8375,427,57,2,54,5,275,5,1])
  11.  
Success #stdin #stdout 0s 6224KB
stdin
Standard input is empty
stdout
[0,1,2,2,5,5,6,8,17,54,54,57,68,275,427,568,8375]