Bubble sort algorithm borrowed from the Scripting Guys.
Case insensitive sorting subroutine.
Sort array_name
Sub Sort( ByRef myArray )
Dim i, j, strHolder
For i = ( UBound( myArray ) - 1 ) to 0 Step -1
For j= 0 to i
If UCase( myArray( j ) ) > UCase( myArray( j + 1 ) ) Then
strHolder = myArray( j + 1 )
myArray( j + 1 ) = myArray( j )
myArray( j ) = strHolder
End If
Next
Next
End Sub
List the contents of an array on screen.
WScript.Echo Join( myArray, vbCrLf )
Subroutine to reverse the order of array elements.
Reverse array_name
Sub Reverse( ByRef myArray )
Dim i, j, idxLast, idxHalf, strHolder
idxLast = UBound( myArray )
idxHalf = Int( idxLast / 2 )
For i = 0 To idxHalf
strHolder = myArray( i )
myArray( i ) = myArray( idxLast - i )
myArray( idxLast - i ) = strHolder
Next
End Sub