473,396 Members | 1,970 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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 2098
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.com> wrote in message
news:%2***************@TK2MSFTNGP15.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
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...
7
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)) ...
0
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...
4
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
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",...
11
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...
7
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...
7
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>;...
5
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...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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
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
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.