HeapSift (Function)
The HeapSift performs a "heap sort" on an array as part of the SortHeapArray function..
Syntax
HeapSift(MyArray, ColIndx1, Size, Order)
Returns (Boolean)
The order of values of the array specified in MyArray are changed as the result of running HeapSift. The HeapSift 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. |
|
ColIndx1 |
Numeric |
Sets starting data element in the array. |
|
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
A "heap sort" may be better suited for sorting of single-dimensional arrays of more than 25 elements compared to a simple sort (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 HeapSift 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 = HeapSift(myArray, 30,-1);