Sort direction for array sorting: order.ascending (smallest first) and order.descending (largest first).
order.ascending and order.descending go in the order argument of array.sort, array.sort_indices and the sorting functions that take one. order.ascending puts the smallest value first and is the default.
Strings sort alphabetically, numbers numerically, and na values go last in either direction.
Constants
| Name | Value | Description |
|---|---|---|
order.ascending | Smallest first; the default. | |
order.descending | Largest first. |
Remarks
array.sortchanges the array in place;array.sort_indicesreturns the indices that would sort it and leaves the array alone.
Example
//@version=6
indicator("Sort order")
arr = array.new<float>()
for i = 0 to 9
arr.push(close[i])
arr.sort(order.descending)
plot(arr.get(0), "Highest of 10", color.green)
plot(arr.get(9), "Lowest of 10", color.red)See also
Runs on Sidechair