473,503 Members | 1,697 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

multi array

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
4 1305
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
1792
by: Eclectic | last post by:
Hey all, I have been using usort to sort my multi dimensional arrays ... function cmp($a, $b){ if($a == $b){ return 0; } return ($a < $b) ? -1 : 1; }
2
10664
by: iop | last post by:
Hello there, I'd like to "parse" an entire multi-dimension array like this : APP APP without knowing "framework" or "config" or anything passed as variables... 'cause it's simple to call...
2
7649
by: ip4ram | last post by:
I used to work with C and have a set of libraries which allocate multi-dimensional arrays(2 and 3) with single malloc call. data_type **myarray =...
5
2533
by: Cant Think Today | last post by:
I have multi-dimesional arrays that can be specifed by the user, e.g 1,2,3,4,5 1,2,3,4,5,6,7,8,9,10 1,2,3,4,5,6 I think a bit of code that will iterate over these arrays to print out the...
6
2218
by: Adam Hartshorne | last post by:
The input to a function of a 3rd party library I want to use requires a double**, which is a multi-dimension array of doubles. I have looked on the net etc and seen several ways of supposedly...
8
2237
by: masood.iqbal | last post by:
All this time I was under the illusion that I understand the concept of multi-dimensional arrays well ---- however the following code snippet belies my understanding. I had assumed all along...
0
1289
by: Kirk Marple | last post by:
an external API that we're using is giving me back video data in a multi-dimensional Array (not byte, just System.Array). so, for an HD quality video, the data is organized as of bytes. i know...
4
4504
by: Robert P. | last post by:
I can easily store a one-dimensional array in viewstate ( see Test1 ) If I try storing a multi-dimensional array in the viewstate it's crapping out on me when it goes to serialize the array (not...
4
3017
by: Balaskas Evaggelos | last post by:
Hi, does anyone know how i can sort a multi-dimensional array by a specific field ? for example i want to sort arr where n=2, but i need the data of every array to follow that order. ...
4
7319
by: =?Utf-8?B?SGVucmlrIFNjaG1pZA==?= | last post by:
Hi, consider the attached code. Serializing the multi-dimensional array takes about 36s vs. 0.36s for the single-dimensional array. Initializing the multi-dimensional array takes about 4s...
0
7199
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7074
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7273
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
5572
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5000
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3161
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3150
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
731
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
374
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.