Lipi Reference
Lipi

Functions

array.sort_indices()

Returns an int array of indexes that would sort the array, leaving the array itself unchanged. `order` is `order.ascending` (the default) or `order.descending`.

Syntax

                array.sort_indices(series array id, series string order) → series array<int>
              

Arguments

id required series array
order series string

Return Type

series array<int>

Example


          //@lipi=2
indicator("array.sort_indices Example", overlay=true)
prices = array.from(open, high, low, close)
idx = array.sort_indices(prices, order.ascending)
// The first index points at the smallest price
plot(array.get(prices, array.get(idx, 0)), title="Lowest of OHLC", color=color.red)