I don't think there is an inbuilt function, but what you need to write is a "bubble sort".
The technique is simple. You repeatedly search through the array swapping contents of variables if they are higher (descending sort) or lower (ascending sort). Whenever you make a swap you set a switch variable on telling you that a swap has been made. Each time you search the array you set the switch OFF to begin. As soon as you do a search without making a swap, and the switch remains off, you know your array is sorted.
Something like (this is not tested)
Const NumberOfElements = 100
Dim MyArray(NumberofElements) 'this is a dynamic array
(Do something to populate the array with values)
Sub BubbleSort
Dim ISwapped as boolean, SwapVar
SortMe:
ISwapped = False
For I = 2 to NumberOfElements
If MyArray(I) < MyArray (I-1) then 'compare < ascending sort: compare > descending sort
SwapVar = MyArray(I)
MyArray(I)=MyArray (I-1)
MyArray(I-1)=SwapVar
ISwapped = True
End If
Next I
If ISwapped = False then Exit Sub else goto SortMe
End Sub
Get the idea? Hope this does it for you. If you are a No-GoTo programmer then you will have to loop into a subroutine or something. Cheers. DavidF
[This message has been edited by David Fletcher (edited 05-11-2001).]