G
Greg
Hi,
Here is a bubble sort for an array in ascending order I've taken from J-Walk
book. Could some one help my modify it to sort a 2D array based on 1st
row(column)?
I only need an ascending order, and I think if it only sorts horizontal
array I'd be fine as well.
Your help is very much appreciated.
VBA:
Sub BubbleSortNumbers(iArray As Variant)
'Sorts the iArray in ascending order
Dim First As Single, Last As Single
Dim lTemp As Single
Dim j As Integer, i As Integer
First = LBound(iArray)
Last = UBound(iArray)
For i = First To Last - 1
For j = i + 1 To Last
If iArray(i) > iArray(j) Then
lTemp = iArray(j)
iArray(j) = iArray(i)
iArray(i) = lTemp
End If
Debug.Print i, iArray(i)
Debug.Print j, iArray(j)
Next j
Next i
End Sub
Here is a bubble sort for an array in ascending order I've taken from J-Walk
book. Could some one help my modify it to sort a 2D array based on 1st
row(column)?
I only need an ascending order, and I think if it only sorts horizontal
array I'd be fine as well.
Your help is very much appreciated.
VBA:
Sub BubbleSortNumbers(iArray As Variant)
'Sorts the iArray in ascending order
Dim First As Single, Last As Single
Dim lTemp As Single
Dim j As Integer, i As Integer
First = LBound(iArray)
Last = UBound(iArray)
For i = First To Last - 1
For j = i + 1 To Last
If iArray(i) > iArray(j) Then
lTemp = iArray(j)
iArray(j) = iArray(i)
iArray(i) = lTemp
End If
Debug.Print i, iArray(i)
Debug.Print j, iArray(j)
Next j
Next i
End Sub