wrote this multiple dimension array bubble sorter that lets you have as many first dimensions as you want. all i could find online were ones that just sort like 2 items in the first dimension. All you do is pass in the array and what number in the second dimension that you want to sort by and the number of items in the second dimension. i used this to sort a message log and it works perfectly. does everything look good to you guys? i figure if someone needs something like this they can use my code or if i just suck at coding that someone can point it out so im not screwing up our data output...lol.
ex.
for an array with x amount of items, each having 7 different attributes, and you want to sort by the first attribute, you would call:
ex.
for an array with x amount of items, each having 7 different attributes, and you want to sort by the first attribute, you would call:
Code:
call DualSorter(thearray, 0,8)
Code:
function DualSorter(byRef arrArray, DimensionToSort, NumDimensions) Dim row, x,j, StartingKeyValue, StartingOtherValue, _ NewStartingKey, NewStartingOther, _ swap_pos, OtherDimension Const column = 1 dim aryStartingValues(6) dim aryNewValues(6) For row = 0 To UBound(arrArray) - 1 for x = 0 to NumDimensions - 1 aryStartingValues(x) = arrArray (row, x) next for x = 0 to NumDimensions - 1 aryNewValues(x) = arrArray (row, x) next swap_pos = row For j = row + 1 to UBound(arrArray) - 1 'Start inner loop. If arrArray (j, DimensionToSort) < aryNewValues(DimensionToSort) Then swap_pos = j for x = 0 to NumDimensions - 1 aryNewValues(x) = arrArray (j, x) next End If Next If swap_pos <> row Then for x = 0 to NumDimensions - 1 arrArray (swap_pos, x) = aryStartingValues(x) next for x = 0 to NumDimensions - 1 arrArray (row, x) = aryNewValues(x) next End If Next End Function