Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sorting Multidimensional Array

Status
Not open for further replies.

Bku

Technical User
Feb 17, 2004
6
US
Hi,
I have a problem. I'm fairly new to VBA and I can't figure out how to sort a multidimensional array by the first column. An example of how to move the whole row based on the first column would help. Thanks.

the array is:

Dim arrVehicles(1 to 10398, 1 to 6)

 
Brute force method (Bubble sort)
Dim arrVehicles(1 to 10398, 1 to 6)
For i=1 To 10398
For j=i+1 To 10398
If arrVehicles(i,1)>arrVehicles(j,1) Then
For k=1 To 6
tmp=arrVehicles(i,k)
arrVehicles(i,k)=arrVehicles(j,k)
arrVehicles(j,k)=tmp
Next k
End If
Next j
Next i
I left as an exercise the use of LBound and UBound

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
Next time search the forums for what you need before posting

thread 222-737779 will help you

thread 222-653793 also

and
thread 222-596644

Probably more, but I can't be bothered searching for more.


Regards

Frederico Fonseca
SysSoft Integrated Ltd
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top