def isort_by
import bend-mathlib@0.8.1.0/perm.bend as Permimport Base
75# Insertion sort by the comparator le.
76def isort_by(~A: Data, ~le: A -> A -> Bool, xs: List<&2, A>) -> List<&2, A>:
77 match xs:
78 case Nil{}:
79 Nil{}
80 case +x <> t:
81 insert_by(~A, ~le, x, isort_by(~A, ~le, t))