Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello,
I use a sorting function (BubbleSort) to sort an array of data. The array is 3 dimentions and it is being sorted by the first. I want it to sort by the first then the second. Can anyone help me with this? Here is the code now: Function BubbleSort(TempArray As Variant) Dim temp(71, 3) As Variant Dim i As Integer Dim NoExchanges As Integer ' Loop until no more "exchanges" are made. Do NoExchanges = True ' Loop through each element in the array. For i = 1 To UBound(TempArray) - 1 ' If the element is greater than the element ' following it, exchange the two elements. If TempArray(i, 1) TempArray(i + 1, 1) Then NoExchanges = False temp(i, 1) = TempArray(i, 1) temp(i, 2) = TempArray(i, 2) temp(i, 3) = TempArray(i, 3) TempArray(i, 1) = TempArray(i + 1, 1) TempArray(i, 2) = TempArray(i + 1, 2) TempArray(i, 3) = TempArray(i + 1, 3) TempArray(i + 1, 1) = temp(i, 1) TempArray(i + 1, 2) = temp(i, 2) TempArray(i + 1, 3) = temp(i, 3) End If Next i Loop While Not (NoExchanges) End Function Thanks, Ernst. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Sorting within an array | Excel Discussion (Misc queries) | |||
Array Sorting in VB | Excel Programming | |||
Sorting 2D portion of 5D Array | Excel Programming | |||
Sorting 2D Array | Excel Programming | |||
Sorting a 2-dimensional array | Excel Programming |