Package: effect
Module: Array
Sorts an array by the given Order, returning a new array.
When to use
Use to sort an array using a single Order comparator.
Details
Preserves NonEmptyArray in the return type. Use sortWith to sort by a
derived key, or sortBy for multi-key sorting.
Example (Sorting numbers)
import { Array, Order } from "effect"
console.log(Array.sort([3, 1, 4, 1, 5], Order.Number)) // [1, 1, 3, 4, 5]
See
sortWith — sort by a mapping functionsortBy — sort by multiple ordersSignature
declare const sort: { <B>(O: Order.Order<B>): <A extends B, S extends Iterable<A>>(self: S) => ReadonlyArray.With<S, ReadonlyArray.Infer<S>>; <A extends B, B>(self: NonEmptyReadonlyArray<A>, O: Order.Order<B>): NonEmptyArray<A>; <A extends B, B>(self: Iterable<A>, O: Order.Order<B>): Array<A>; }
Since v2.0.0