Syntax
|
ArraySort
array()
|
Description
|
Sorts a single-dimensioned array in ascending order.
|
Comments
|
If a string array is specified, then the routine sorts alphabetically in ascending order using case-sensitive string comparisons. If a numeric array is specified, the
ArraySort
statement sorts smaller numbers to the lowest array index locations.
The script generates a runtime error if you specify an array with more than one dimension.
When sorting an array of variants, the following rules apply:
- A runtime error is generated if any element of the array is an object.
-
String
is greater than any numeric type.
-
Null
is less than
String
and all numeric types.
-
Empty
is treated as a number with the value 0.
String comparison is case-sensitive (this function is not affected by the
Option Compare
setting).
|
Example
|
This example dimensions an array and fills it with filenames using FileList, then sorts the array and displays it in a select box.
Sub Main()
Dim f$()
FileList f$,"c:\*.*"
ArraySort f$
r% = SelectBox("Files","Choose one:",f$)
End Sub
|
See Also
|
ArrayDims (function); LBound (function); UBound (function)
|