dhall-nix-lib/Integer/sort.dhall

21 lines
606 B
Text

--| `sort` sorts a `List` of `Integer`s in ascending order
λ(nix : ../NixPrelude.dhall) →
let Any = ../Any/Type.dhall
let Any/toAny = ../Any/toAny.dhall nix
let Any/toTypeUnchecked = ../Any/toTypeUnchecked.dhall nix
let Any/lessThan = ../Any/lessThan.dhall nix
let coerceList =
λ(from : Type) →
λ(to : Type) →
λ(list : List from) →
Any/toTypeUnchecked (List to) (Any/toAny (List from) list)
in λ(xs : List Integer) →
coerceList
Any
Integer
(nix.builtins.sort Any/lessThan (coerceList Integer Any xs))