Code
Public Function SortSArray(pArray() As String, pCompare As VbCompareMethod) As String()
'Function
'   Used to sort a specified string array.
'Parameters
'   pArray (String()) = The array to sort.
'   pCompare (vbCompareMethod) = Determines what type of search will be done.
'       Valid Values: vbTextCompare, vbBinaryCompare
'Return (String())
'   Returns pArray sorted according to the method specified by pCompare.
'   If pArray is an empty array, function returns and empty array.
'Notes
'   This function works with non-zero-based arrays.
'Version History
'   1.0 Tested 7/22/03
'---

'Initiate variables
Dim InsIndex As Long 'the index where the current element is to be inserted
Dim R() As String 'return buffer
Dim C  As Long 'counter

'Trap: pArray is empty, return and empty array and exit now
If ElementCount(pArray) = 0 Then
    SortSArray = R
    Exit Function
End If

'Loop through and sort each element in pArray
'For C = 0 To ElementCount(pArray) - 1
For C = LBound(pArray) To UBound(pArray)

    'Get the index where the element should be inserted in the return buffer
    InsIndex = SortIndexOfSArray(R, pArray(C), pCompare)

    'Append 1 element to the end of the return buffer to make room for the new element
    ReDim Preserve R(ElementCount(R))

    'Create room for the string to be inserted by shifting all elements below the index down one position
    R = ShiftSArray(R, InsIndex, UBound(R) - 1, 1)

    'Insert the element from our original array into the return buffer
    R(InsIndex) = pArray(C)

Next C

'Return result
SortSArray = R

End Function


The Captian
Today they call you "crazy". Tomorrow they call you "ahead of your time."
Global Skywatch Learn about Chemtrails - You're breathing them now!
OnlyTheBestHerbs.com World-class supplements
Mercury Talk Why you are sick.
OneUp Domains Domains, Hosting, Email
1-800-358-4278 (U.S. & Canada)