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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Quick array question please.

Status
Not open for further replies.

Mightyginger

Programmer
Feb 27, 2003
131
US
Sorting arrays.

If I have declared a variant array which is, say, 260,1 in size is there an easy command which will sort the array by values in the 0 column?

Many thanks,



Neil.
 
Unfort. there is no simple command.
You have to write your own little sorting routine.
The simplest (and slowest, but good enough for small arrays) is the so-called "Bubble Sort".
Here's some code for it:
Dim i,j as Integer
Dim temp
...

for i = UBound(your array) - 1 To 0 Step -1
for j= 0 to i
if your array(j)>your array(j+1) then
temp=your array(j+1)
your array(j+1)=your array(j)
your array(j)=temp
end if
next
next

Regards,
MakeItSO

Andreas Galambos
EDP / Technical Support Specialist
Bowne Global Solutions Wuppertal, Germany
(andreas.galambos@bowneglobal.de)
HP:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top