append:(list(int),list(int))list(int)
split:(int,list(int))[list(int),list(int)]
sort:(list(int))list(int)

fun append(l,r) = match l with
	nil => r
	| cons(d,h,t) => cons(d,h,append(t,r))

fun split(p,l) = match l with
	nil => [nil(int) ,nil(int)]
        | cons(d,h,t) => match split(p,t) with
			[u,v] => if h<p then [cons(d,h,u),v]
					else [u,cons(d,h,v)]
fun sort(l) = match l with
	nil => nil(int)
        | cons(d,p,t) => match split(p,t) with
			[u,v] => append(sort(u),cons(d,p,sort(v)))