Hi there,
I need to sort multi-dimensional array by two columns. I.e. I have the following:
a b c
-----------
1 12 1
0 10 2
1 10 3
1 15 4
0 14 5
So the result should look like this:
a b c
-----------
1 15 4
1 12 1
1 10 3
0 14 5
0 10 2
As you can see I need to order it in descending order by column A first and then by column B so that column C should still be mapped appropriately.
When I had just 2 columns (B and C) it was pretty easy to do:
Hashtable HTPreferenceOrd er = new Hashtable();
//next line is in loop
HTPreferenceOrd er.Add(B,C);
//end loop
int count= HTPreferenceOrd er .Count;
int[] B= new int[count];
int[] C= new int[count];
HTPreferenceOrd er.Keys.CopyTo( B,0);
HTPreferenceOrd er.Values.CopyT o(C, 0);
Array.Sort(B, C);
Array.Reverse(C );
That's it. I got column C in descending order like i wanted it to be. But now i had to add column A and sort by it first. Please help, need to do it ASAP.
Thanks in advance.
2 1515
Have you tried doing the same with column A?
Have you tried doing the same with column A?
Do what with column A? I can't do it with column A because i need it to be sorted by column A and column B and so column C is still mapped appropriately.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: WU FUHENG |
last post by:
Today,I found a strange problem in python multi-thread programming.When I used function win32com.client.Dispatch('ADODB.Connection') in primary thread, it was OK. But when I called it in secondary-thread, it raised a exception. Then debugging and tracking the code, I found the problem was from the function pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch) in . The parameters are (ADODB.Connection, None, 21,...
|
by: mikeswk |
last post by:
Hi, all
I'm using jsp to connect to mysql 3.23.44 max using connector 3.0.6 (default
charset=latin1)
I'm trying to put some multi-byte characters (for example big5) together
with latin characters into 1 table field. Is it possible?
I tried to set the content type to 8859_1 using jsp (and the result html
code is set to big5 in the meta tag), so that it can be inserted the big5
characters and displayed correctly (using 8859_1) also. But...
|
by: Andrew V. Romero |
last post by:
First off, I am mostly familier with PHP but am trying to make a
multi-step javascript program. For an example, I would like to run
different sections of the script depending on how many times the user
presses the submit button:
<form method="post" name="step1" action="test.html">
<script language="JavaScript">
var position
|
by: Jon Skeet [C# MVP] |
last post by:
Please excuse the cross-post - I'm pretty sure I've had interest in the
article on all the groups this is posted to.
I've finally managed to finish my article on multi-threading - at least
for the moment. I'd be *very* grateful if people with any interest in
multi-threading would read it (even just bits of it - it's somewhat
long to go through the whole thing!) to check for accuracy,
effectiveness of examples, etc.
Feel free to mail...
|
by: Dr. Ann Huxtable |
last post by:
Hello All,
I am reading a CSV (comma seperated value) file into a 2D array. I want
to be able to sort multiple columns (ala Excel), so I know for starters,
I cant be using the array, I need something more sophistictated like a
vector of row objects.
The data is of this format (same number of columns for each row):
A, x, y, z, ...
| |
by: P Adhia |
last post by:
Hello,
If the explain shows that DB2 needs to sort the result of a cursor,
does that always happen? i.e. if the resultset of the cursor is empty,
does the sort have any overhead? It appears that, majority of the time
is spent in allocation and deallocation of the temporary file to hold
the data for the sort. Do these activities still take place for an
empty cursor?
Also, DB2 manual appears to say that only RID sorts are done in
|
by: Nicolas |
last post by:
Hello,
Please excuse me if I am a little off-topic. I would like to know what
graphical library is the best to use for a multiplatform (Windows, Mac Os,
Linux) application. I know GTK, but it is pretty difficult to install for
unexperienced users, and I think it can't be statically linked.
Thanks a lot for your advices,
Nicolas
|
by: xahlee |
last post by:
Last year, i've posted a tutorial and commentary about Python and
Perl's sort function. (http://xahlee.org/perl-python/sort_list.html)
In that article, i discussed a technique known among juvenile Perlers
as the Schwartzian Transform, which also manifests in Python as its
“key” optional parameter.
Here, i give a more detailed account on why and how of this construct.
----
|
by: jehugaleahsa |
last post by:
Hello:
I want to know the best way to sort a BindingList without needed to
turn it into a DataTable. Of course, my BindingList is being used
indirectly by a BindingSource.
So, how do I sort a BindingList of my custom business objects? For
instance, when the user clicks on a column header of a DataGridView, I
would like sorting to be handled for me (or to call a custom sort
method I provide).
|
by: jim |
last post by:
Each night, a scheduled task copies certain information from an MS
Access db to a MySQL db that serves as a data warehouse. I would like
to begin replicating multi-value fields from Access to MySQL, but when
I try I run into the "unable to insert multi-value fields..." error.
Does anyone know of a way around this? I would be satisfied with
being able to treat all values in the multi-value list as a single
text string with some sort of...
|
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,...
| |
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...
|
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 projectplanning, coding, testing, and deploymentwithout 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...
|
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...
|
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();...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |