AfxSortNumericArrayfunction
Sorts one-dimensional numeric arrays of any type.
Parameters
| Name | Description | |
|---|---|---|
rg | The array to sort. | |
ascending | If true, sorts the array in ascending order. I false, sorts the array in descending order. |
Description
Sorts one-dimensional numeric array of any type. The macro detects the type of array and calls the appropriate sorting procedures.
Examples
#macro AfxSortNumericArray(rg, ascending)
#define XNUMBER DOUBLE ' // or SHORT, INTEGER, LONG, LONGINT, etc. DIM rgNum(ANY) AS XNUMBER DIM rgNum2(ANY) AS XNUMBER DIM xNum AS XNUMBER = 1234567.89 ' // Fill the array FOR i AS LONG = 1 TO 10 xNum += 0.01 AppendElementToArray(rgNum, xNum) NEXT ' Fill the array to insert xNum = 111.01 FOR i AS LONG = 1 TO 5 xNum += 1 AppendElementToArray(rgNum, xNum) NEXT ' // Insert the array to the first array InsertArrayIntoArray(rgNum, 5, rgNum2) ' // Display the array FOR i AS LONG = LBOUND(rgNum) TO UBOUND(rgNum) print rgNum(i) NEXT ' // Sort the numeric array AfxSortNumericArray(rgNum, true) ' // Display the sorted array FOR i AS LONG = LBOUND(rgNum) TO UBOUND(rgNum) print rgNum(i) NEXT
Reference
- Include file
AfxArrays.inc - Documented in String Management/Array Macros.md
- Topic: Array Macros