dhall-nix-lib/Number/sort.dhall

23 lines
631 B
Text

--| `sort` sorts a `List` of `Number`s in ascending order
λ(nix : ../NixPrelude.dhall) →
let Number = ./Type.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 Number) →
coerceList
Any
Number
(nix.builtins.sort Any/lessThan (coerceList Number Any xs))