Sort
Sorts an array in ascending order using an adaptive strategy.
Module: Std::Sort
Signature
rux
func Sort(arr: *int, len: uint);
func SortUint64(arr: *uint64, len: uint);Parameters
| Name | Type | Description |
|---|---|---|
arr | *int / *uint64 | Pointer to the first element. |
len | uint | Number of elements to sort. |
Description
The recommended general-purpose sort. It picks the best underlying algorithm for the input size: Quadsort for small arrays (≤ 128 elements) and Crumsort for larger ones. Sorting happens in place.
WARNING
The *int form compares values as unsigned — negative numbers sort after non-negative ones. See the module overview.
Example
rux
import Std::Sort;
var data: uint64[4] = { 30u64, 10u64, 20u64, 5u64 };
Sort::SortUint64(data.data, data.length);
// { 5, 10, 20, 30 }