let rec insert(e, l): int list =
  match l with
     [] -> [e]
  | x::xs -> if e < x then e::l else x::(insert(e,xs))

let rec isort' (l1, l2): int list =
  match l1 with
     [] -> l2
  | x::xs -> isort'(xs, insert(x, l2))

let isort(l: int list): int list =
  isort'(l, [])