multi array sort
multi array sort
(OP)
I have this:
v(0, 0) = 4
v(0, 1) = 100
v(1, 0) = 5
v(1, 1) = 800
v(2, 0) = 2
v(2, 1) = 200
v(3, 0) = 6
v(3, 1) = 50
v(4, 0) = 1
v(4, 1) = 550
And I want this:
v(0,0)= 1
v(0,1)=550
v(1,0)= 2
v(1,1)=200
v(2,0)= 4
v(2,1)=100
v(3,0) = 5
v(3,1)=800
v(4,0) = 6
v(4,1)=50
How can I code it?
v(0, 0) = 4
v(0, 1) = 100
v(1, 0) = 5
v(1, 1) = 800
v(2, 0) = 2
v(2, 1) = 200
v(3, 0) = 6
v(3, 1) = 50
v(4, 0) = 1
v(4, 1) = 550
And I want this:
v(0,0)= 1
v(0,1)=550
v(1,0)= 2
v(1,1)=200
v(2,0)= 4
v(2,1)=100
v(3,0) = 5
v(3,1)=800
v(4,0) = 6
v(4,1)=50
How can I code it?
RE: multi array sort
Your problem is to sort a group of records, on the value of a particular column.
I do not know what your program exactly does, but I think it collects multiple sets of related data, and analyzes them. In order to solve this type of problems systematically, you need to understand any (or both) of the two following concepts.
1. User-defined data-structures
2. Database
These topics are a bit elaborate, so cannot be explained here. But, these are explained in any intermediate-level VB book.
I could send an example code for solving this, but for some reason I consider that pointless, without explaining the concept.
Regards
Yeasir Rahul
Principal, VoltSmith Technologies
www.voltsmith.com
RE: multi array sort
RE: multi array sort
e.g.
Dim ccol As Collection
Set ccol = New Collection
' note that the order that the data is entered is unimportant
ccol.Add Key:=Str(2), Item:=200
ccol.Add Key:=Str(1), Item:=550
' ...
Debug.Print ccol(Str(1))
Debug.Print ccol(Str(2))
' ...