Sort
- performs a quick sort of the array

Miscellaneous functions
(AFL 3.90)


SYNTAX Sort( array, first = 0, last = -1, indexmode = False )
RETURNS ARRAY
FUNCTION Sorts a numerical array in ascending order starting from first element ending at last element. If last is not specified or negative then AmiBroker will use BarCount - 1.

If indexmode = 0 then returned array holds actual sorted values, if indexmode = 1 the function returns array of indexes to the sorted values instead of values themselves. So if first returned value is 2923 it means that input array[ 2923 ] is the smallest element.

EXAMPLE Filter = 1;
AddColumn( BarIndex(), "Bar Index", 1.0 );
AddColumn( Close, "Close" );
// normal mode
AddColumn( Sort( Close ), "Sorted Close" );
// index mode
AddColumn( Sort( Close, 0, -1, True ), "Index of sorted item", 1.0 );
SEE ALSO

References:

The Sort function is used in the following formulas in AFL on-line library:

More information:

Updated on-line reference