multi array

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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?
 
Use a mapping array

m(0)
m(1)
m(1)
m(1)
m(1)


--
OHM ( Terry Burns ) * Use the following to email me *

Dim ch() As Char = "ufssz/cvsotAhsfbuTpmvujpotXjui/OFU".ToCharArray()
For i As Int32 = 0 To ch.Length - 1
ch(i) = Convert.ToChar(Convert.ToInt16(ch(i)) - 1)
Next
Process.Start("mailto:" & New String(ch))
 
This is a really good question, however you can use a mapping array to match
the two.


--
OHM ( Terry Burns ) * Use the following to email me *

Dim ch() As Char = "ufssz/cvsotAhsfbuTpmvujpotXjui/OFU".ToCharArray()
For i As Int32 = 0 To ch.Length - 1
ch(i) = Convert.ToChar(Convert.ToInt16(ch(i)) - 1)
Next
Process.Start("mailto:" & New String(ch))
 
Basically, you want to sort on the first dimension, right?
That shouldn't be too hard - you simply need to implement one of the many
sorting algorithms out there and modify them to support 2-dimensional
arrays. Here's a sample code I found while googling:

http://www.freevbcode.com/ShowCode.asp?ID=2530

Its for VB6 but shouldn't be hard to port to VB.NET.

hope that helps...
Imran.
 
You can also use a class for the values and a single dimension array of the
classes. You can then sort by using an Icomarer class to sort on whatever
value you want. You can have as many different propertys in the class as you
want then sort on any one of them.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top