Sidechair

order.* constants

Browse the reference

Sort direction for array sorting: order.ascending (smallest first) and order.descending (largest first).

Try it in the editor

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

NameValueDescription
order.ascendingSmallest first; the default.
order.descendingLargest first.

Remarks

  • array.sort changes the array in place; array.sort_indices returns the indices that would sort it and leaves the array alone.

Example

Pine ScriptHighest closes firstOpen in editor
//@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