Support

Equilla Formula Language

CreateSortedIndexArray

Creates a sorted index into an array. The array containing the actual data will remain unchanged. If IndexArray is a dynamic array, it gets resized to the length of DataArray. If IndexArray is fixed-size and the length of DataArray exceeds its length then a runtime error will be raised, otherwise all elements not containing an index into DataArray will be reset to the declared default value of IndexArray.

Inputs

DataArray
Array: The array containing the data to be sorted.
IndexArray
ArrayRef: The array receiving the sorted indices.
Order
Boolean: (Optional) Sort elements in ascending order.

Remarks

Prior to version 6.2, CreateSortedIndexArray processed the element at index 0 to be compatible with the vector function CreateSortedIndexVector. If you have indicators or strategies depending on this behaviour, you can use the array function CreateSortedIndexArrayLegacy.

Examples

Create a sorted index
Arrays: myDataArray[], myIndexArray[3]; FillArray( myDataArray, 4, 6, -5 ); CreateSortedIndexArray( myDataArray, myIndexArray ); Print( myIndexArray ); // prints 3 1 2