By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,702 Members | 1,760 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,702 IT Pros & Developers. It's quick & easy.

multi array

P: n/a
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?
Nov 21 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
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))
--
<an*******@discussions.microsoft.com> wrote in message
news:04****************************@phx.gbl...
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?

Nov 21 '05 #2

P: n/a
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))
--
<an*******@discussions.microsoft.com> wrote in message
news:04****************************@phx.gbl...
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?

Nov 21 '05 #3

P: n/a
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.

<an*******@discussions.microsoft.com> wrote in message
news:04****************************@phx.gbl...
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?

Nov 21 '05 #4

P: n/a
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.

"Imran Koradia" wrote:
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.

<an*******@discussions.microsoft.com> wrote in message
news:04****************************@phx.gbl...
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?


Nov 21 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.