sort 2D array
- From: "Greg" <Greg@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 6 Feb 2006 13:27:45 -0800
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
--
______
Regards,
Greg
.
- Follow-Ups:
- RE: sort 2D array
- From: Toppers
- RE: sort 2D array
- Prev by Date: Re: Momentarily Display Splash Screen
- Next by Date: RE: Macro Help
- Previous by thread: trying to get formula in cell
- Next by thread: RE: sort 2D array
- Index(es):
Relevant Pages
|