SortHeapArray (Function)

image\trumpet2.gif Disclaimer

The SortHeapArray performs a heap sort on the values of a one-dimensional array in either ascending or descending order.

Syntax

SortHeapArray(PriceArray, Size, Order)

Returns (Boolean)

The order of values of the array specified in PriceArray are changed as the result of running SortHeapArray.  The SortHeapArray function itself returns True.

Parameters

Name

Type

Description

MyArray

Numeric Array

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

Size

Numeric

Sets the number of data elements (size) in the array to evaluate.

Order

Numeric

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

Remarks

SortHeapArray may be better suited for sorting of single-dimensional arrays of more than 25 elements compared to the alternate function SortArray (that may be faster for arrays of 25 or fewer elements).  

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

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

Example

Performs an ascending sort of the user declared array..

Array: myArray[30](0);

{… (assign values to array) }

Value1 = SortHeapArray(myArray, 30,-1);