let rec sort = let rec insert elt lst = match lst with [] -> [elt] | head :: tail -> if elt <= head then elt :: lst else head :: insert elt tail in fun lst -> match lst with [] -> [] | head :: tail -> insert head (sort tail);; (* This is a fairly simple sort but it is n^2. *)