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? 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?
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?
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?
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? This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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;
}
|
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...
|
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
=...
|
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...
|
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...
| |
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...
|
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...
|
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...
|
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.
...
|
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...
|
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,...
| |
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...
|
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,...
|
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,...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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...
| |