{
    Let list_insertion compare input.
        (LIST.reduce input []
            Func sorted elem.
                Begin (inserting [] sorted)
                    Define inserting left right.
                        Match right
                        | `nil (LIST.reverse (elem::left))
                        | `cons.{elem' right'}
                            Match (compare elem elem')
                            | `less (LIST.reverse_append left (elem::right))
                            | _ Goto (inserting (elem'::left) right')
                            ;
                        ;)
}

Where

Let LIST. Package "list"