Bubble Sort in VBS

This is the code required to sort an array in alphabetical order (you need UCase to convert the lower case to upper case, because VB sorts on ASCII value and the value of upper case characters is higher than that of lower case characters.

For i = (UBound(arrNames) - 1) to 0 Step -1
For j= 0 to i
If UCase(arrNames(j)) > UCase(arrNames(j+1)) Then
strHolder = arrNames(j+1)
arrNames(j+1) = arrNames(j)
arrNames(j) = strHolder
End If
Next
Next

Bubble sort is not the most efficient way for sorting and should not be used on large arrays.

For more information on bubble sort: http://en.wikipedia.org/wiki/Bubble_sort