packages feed

hat-2.7.0.1: examples/Insort.hs

-- Simple insertion sort

sort :: Ord a => [a] -> [a]
sort []	=	[]
sort (x:xs)	=	insert x (sort xs)

insert :: Ord a => a -> [a] -> [a]
insert x []	=	[x]
insert x (y:ys)	=	if x <= y then x : y : ys
 	 	else y : insert x ys

main	=	putStrLn (sort "program")