-
Notifications
You must be signed in to change notification settings - Fork 0
sort
ffredyk edited this page Jul 23, 2026
·
1 revision
Array
Binary — <array> sort <ascending>.
<array> sort <boolean> // true = ascending, false = descending
Sorts the array in-place. The right operand is a Boolean: true for ascending order, false for descending order. nil values always sort to the end regardless of direction. Returns nil.
Calls List<Value>.Sort() with a custom comparer. The comparer handles nil values by placing them at the end. For numbers and strings, uses natural ordering. Sorting is unstable — equal elements may change relative order.
_arr = [3, 1, 4, 1, 5];
_arr sort true; // [1, 1, 3, 4, 5]_scores = [10, 45, 22, 98];
_scores sort false; // [98, 45, 22, 10]_arr = [5, nil, 2, nil, 9];
_arr sort true; // [2, 5, 9, nil, nil] — nils to end
_arr sort false; // [9, 5, 2, nil, nil]_names = ["Charlie", "Alice", "Bob"];
_names sort true; // ["Alice", "Bob", "Charlie"]_scores = [];
{ _scores pushBack (random 100) } forEach [1,2,3,4,5];
_scores sort false; // sort best-first
_top3 = [_scores select 0, _scores select 1, _scores select 2];Not thread-safe. Array must belong to the current scheduler.
- Getting Started
- Language Guide
- Type System
- Control Flow
- Functions & Code
- Strings & Text
- Arrays & Collections
- Concurrency
- Promise System
- Thread Safety
- Host API & Embedding
- CLI Tool
- Bytecode Reference
- Multiplayer
- Syntax Sugar
- Optimization Guide
- Benchmarks
- count
- select
- pushBack
- append
- deleteAt
- deleteRange
- resize
- reverse
- sort
- find
- in
- forEach
- freeze
- thaw
- isFrozen
- currentScheduler
- clientOwner
- allSchedulers
- schedulerName
- schedulerExists
- schedulerBudget
- setSchedulerBudget
- fiberCount
- readyFiberCount
- waitingFiberCount
- schedulerLoad
- sendTo