Sub ArraySort(aArrayToSort, sOrder)
‘This script is provided under the Creative Commons license located
‘at http://creativecommons.org/licenses/by-nc/2.5/ . It may not
‘be used for commercial purposes with out the expressed written consent
‘of NateRice.com
‘This Sub will sort the array passed as aArrayToSort
For i = UBound(aArrayToSort) – 1 To 0 Step -1
For j = 0 To i
If aArrayToSort(j) < aArrayToSort(j+1) And sOrder = “desc” Then
sTempStr = aArrayToSort(j+1)
aArrayToSort(j+1) = aArrayToSort(j)
aArrayToSort(j) = sTempStr
ElseIf aArrayToSort(j) > aArrayToSort(j+1) And sOrder = “asc” Then
sTempStr = aArrayToSort(j+1)
aArrayToSort(j+1) = aArrayToSort(j)
aArrayToSort(j) = sTempStr
End If
Next
Next
End Sub
Sub DoubleArraySort(aArray1ToSort, aArray2ToSort, sOrder)
‘This script is provided under the Creative Commons license located
‘at http://creativecommons.org/licenses/by-nc/2.5/ . It may not
‘be used for commercial purposes with out the expressed written consent
‘of NateRice.com
‘This Sub will sort the array passed as aArray1ToSort,
‘the values in aArray2ToSort, will not be sorted, but
‘will be reordered in the same relational order as
‘aArray1ToSort
For i = UBound(aArray1ToSort) – 1 To 0 Step -1
For j = 0 To i
If aArray1ToSort(j) > aArray1ToSort(j+1) And sOrder = “desc” Then
sTempStr = aArray1ToSort(j+1)
aArray1ToSort(j+1) = aArray1ToSort(j)
aArray1ToSort(j) = sTempStr
sTempStr = aArray2ToSort(j+1)
aArray2ToSort(j+1) = aArray2ToSort(j)
aArray2ToSort(j) = sTempStr
ElseIf aArray1ToSort(j) < aArray1ToSort(j+1) And sOrder = “asc” Then
sTempStr = aArray1ToSort(j+1)
aArray1ToSort(j+1) = aArray1ToSort(j)
aArray1ToSort(j) = sTempStr
sTempStr = aArray2ToSort(j+1)
aArray2ToSort(j+1) = aArray2ToSort(j)
aArray2ToSort(j) = sTempStr
End If
Next
Next
End Sub