473,810 Members | 2,935 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Sorting multiple dimensions of an array

Hi All,

Is there a way to sort multiple dimensions of an array in VB.NET? Let's say
I have the following in a multi-dimension array:

3081 100 2
3081 100 1
3081 20 1
3081 1 2
3021 100 2
3021 100 1
3021 20 1
3021 1 2

I need to sort the first dimension, then the 2nd, then the 3rd, to get:

3021 1 2
3021 20 1
3021 100 1
3021 100 2
3081 1 2
3081 20 1
3081 100 1
3081 100 2

Initially, I put the values together in one string, like 3021-1-2 in a
single dimension array, then sorted that, but, because the value is a
string, the sort result is not what I'm looking for. Instead, I get:

3021-1-2
3021-100-1
3021-100-2
3021-20-1
etc.

I know I can create a dataset, table, columns, etc. and use a grid that
supports multi-column sorting, but I don't need the grid. I just need to
sort the array.

Eventually, this data is combined with other data and streamed out to a
file. I can live with the string sort as above, but I'd prefer to sort the
multi-dimension array so that the result is a correct numeric sort.

any ideas?

TIA

Lee
Nov 21 '05 #1
2 2117
lgbjr,

I know I can create a dataset, table, columns, etc. and use a grid that
supports multi-column sorting, but I don't need the grid. I just need to
sort the array.

I miss something above can you tell me what?

http://www.windowsformsdatagridhelp....7-d6ad9bebf57f

You can of course make as well a routine using the icomparer, however for me
it would be to much work because this is so easy to do.

I hope this helps,

Cor
Nov 21 '05 #2

"lgbjr" <lg***@nospam.c om> wrote in message
news:%2******** *******@TK2MSFT NGP15.phx.gbl.. .
Hi All,

Is there a way to sort multiple dimensions of an array in VB.NET? Let's say I have the following in a multi-dimension array:

3081 100 2
3081 100 1
3081 20 1
3081 1 2
3021 100 2
3021 100 1
3021 20 1
3021 1 2

I need to sort the first dimension, then the 2nd, then the 3rd, to get:

3021 1 2
3021 20 1
3021 100 1
3021 100 2
3081 1 2
3081 20 1
3081 100 1
3081 100 2


Seems 2 me that since the dimensions are apparently not related, it would be
easier to just use 3 separate arrays, then sort each separately.
Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2987
by: Paul Kirby | last post by:
Hello All I am trying to update me code to use arrays to store a group of information and I have come up with a problem sorting the multiple array :( Array trying to sort: (7 arrays put into an array) and I want to sort on Descending. This is displayed using print_r() function. Array
7
3270
by: Federico G. Babelis | last post by:
Hi All: I have this line of code, but the syntax check in VB.NET 2003 and also in VB.NET 2005 Beta 2 shows as unknown: Dim local4 As Byte Fixed(local4 = AddressOf dest(offset)) CType(local4, Short) = CType(src, Short)
0
3244
by: Brian Henry | last post by:
Here is another virtual mode example for the .NET 2.0 framework while working with the list view. Since you can not access the items collection of the list view you need to do sorting another way... here is my code on how I did it to help anyone starting out get an idea of how to use virtual mode in ..NET 2.0 Imports CrystalDecisions.CrystalReports.Engine Imports CrystalDecisions.Shared
4
2176
by: rushik | last post by:
Hello all, I am using structure in my program, and my aim is to sort this structure based on some optimized sorting algo. structure is struct data { int account;
1
4014
by: Steph | last post by:
Hello, i dot not manage to write the code to sort a array on multiple columns. ArrayList people = new ArrayList(); people.Add(new Person("John", "Doe", 76)); people.Add(new Person("Matt", "Dire", 80)); people.Add(new Person("Matew", "Vinz", 75)); people.Add(new Person("Arlett", "Blaste", 84)); so, i want now sorting by Name, Surname and Year :
11
18335
by: dwelden | last post by:
I have successfully used the sort lambda construct described in http://mail.python.org/pipermail/python-list/2006-April/377443.html. However, how do I take it one step further such that some values can be sorted ascending and others descending? Easy enough if the sort values are numeric (just negate the value), but what about text? Is the only option to define an external sorting function to loop through the list and perform the...
7
1925
by: Steve Bergman | last post by:
I'm involved in a discussion thread in which it has been stated that: """ Anything written in a language that is 20x slower (Perl, Python, PHP) than C/C++ should be instantly rejected by users on those grounds alone. """ I've challenged someone to beat the snippet of code below in C, C++, or assembler, for reading in one million pairs of random floats and
7
2164
by: Rob | last post by:
This actually compiles and works but it doesn't seem like the best code, so I was wondering is there another way to do this? template <typename Tvector<T>* addDepth(T) { return new vector<T>; } ....a templated meth...
5
4962
by: jrod11 | last post by:
hi, I found a jquery html table sorting code i have implemented. I am trying to figure out how to edit how many colums there are, but every time i remove code that I think controls how many colums there are, it crashes. There are currently 6 columns, and I only want 4. How do I remove the last two (discount and date)? Here is a link: http://www.jaredmoore.com/tablesorter/docs/salestable.html Here is some jquery js that I think...
0
9722
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9603
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10644
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10379
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9200
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7664
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6882
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5550
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5690
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.