sorindragan
3/20/2018 - 6:42 PM

InsertionSort in Haskell

InsertionSort algorithm in Haskell

sort []  = []
sort [x] = [x]
sort (x:xs) = insert (sort xs)
    where insert [] = [x]
          insert (y:ys) | x <= y    = x : y : ys
                        | otherwise = y : insert ys