@lang:sort
Sort an array: ascending by default, desc for descending, or by a comparator helper.
On-chain (@lang:sort!): Supports natural word ordering or an ABI-typed comparator definition, including composed expressions; equal elements retain their order.
Returns: array
Syntax
Section titled “Syntax”@lang:sort(arr order?)Arguments
Section titled “Arguments”| Name | Type | Description |
|---|---|---|
arr | array | Source array |
[order] | helper | string | asc (default) or desc, or a comparator helper returning a number |
See Also
Section titled “See Also”- @reverse — reverse an array
On-chain face (@sort!)
Section titled “On-chain face (@sort!)”Sort word values naturally, or provide a named comparator returning a signed integer: negative for before, zero for equal, positive for after. Typed multiword values require a comparator. Comparators may compose helpers and ABI calls. Equal elements retain their relative order.
Inputs may be homogeneous literals, live fixed-size or dynamic arrays, or nested
on-chain collection helpers. Negative numeric literals select int256; otherwise
numeric literals select uint256. An untyped empty literal defaults to uint256[].
Callback parameter types must remain compatible with the inferred element type.