Sort2DArray (Function)

image\trumpet2.gif Disclaimer

The Sort2DArray function performs a linked sort of values in a two dimensional array, using the primary dimension as the key.  

Syntax

Sort2DArray(PriceArray, Size1, Size2, HiLo)

Parameters

Name

Type

Description

PriceArray

Numeric Array

Specifies the name of a numeric array containing values upon which the sort is performed.

Size1

Numeric

Sets the number of array elements (size) in the 1st dimension to be sorted.

Size2

Numeric

Sets the number of array elements (size) in the 2nd dimension to include in the sort.

HiLo

Numeric

Sets the sort order.   1 = sort descending,   -1 = sort ascending

Returns (Double)

The order of values of the two-dimensional array specified in PriceArray are changed as the result of running Sort2DArray.   The Sort2DArray function itself returns 1.

Remarks

This function is used to change the order of values in an array by sorting them in either ascending or descending order based on the HiLo input.  The sort is performed using the elements of the 1st dimension as a key.

The value for the Size1 and Size2 input parameters should always be a whole number greater than 0 and is typically equal to the number of data elements in the array.

The Sort2DArray function only works with two-dimensional arrays.  All array-based referencing begins with array element 1.

Example

Performs an ascending sort of the user declared two-dimensional array..

Array: myArray[30,4](0);

{… (assign values to array) }

Value1 = Sort2DArray(myArray, 30, 4, -1);