473,320 Members | 1,909 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,320 software developers and data experts.

How to sort an arraylist

Y
Hi I have an arraylist that contains integer values. What i want to ask you all is how i would retrieve the index values when the values have been sorted. For example..
lets assume the index values are in brackets and the values contained in it is shown immeditaly preceding it.

Arraylist1
(0)4 , (1)2, (2)1, (3)2, (4)0, (5)

i want the arraylist to now be sorted according to the values contained in it (smallest integer first). However i want the index values maintained. i.

(4)0, (2)1, (1)2, (3)2, (5)3, (0)

I then want the Index values retrieved in the order above
i.e i want this order of index's retrieved.
(4), (2), (1), (3), (5), (0

Can anyone tell me if this is possible?
ANy help would really be appreciated

thankU
Nov 22 '05 #1
1 1269
Y, if you want to be able to retrieve the original indexes, I'd can the
Arraylist and use a hashtable. Store the original index as your key and the
integer (4, 2, 1, 2, 0, 3 ) as your values. You can find either one if you
know it's counterpart.

HTH,

Bill
"Y" <an*******@discussions.microsoft.com> wrote in message
news:E2**********************************@microsof t.com...
Hi I have an arraylist that contains integer values. What i want to ask you all is how i would retrieve the index values when the values have been
sorted. For example... lets assume the index values are in brackets and the values contained in it is shown immeditaly preceding it..
Arraylist1.
(0)4 , (1)2, (2)1, (3)2, (4)0, (5)3

i want the arraylist to now be sorted according to the values contained in it (smallest integer first). However i want the index values maintained. i.e
(4)0, (2)1, (1)2, (3)2, (5)3, (0)4

I then want the Index values retrieved in the order above.
i.e i want this order of index's retrieved..
(4), (2), (1), (3), (5), (0)

Can anyone tell me if this is possible??
ANy help would really be appreciated.

thankU

Nov 22 '05 #2

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

Similar topics

1
by: Gunjan Garg | last post by:
Hello All, I am working to create a generic datagrid which accepts a datasource(ListData - This is our own datatype) and depending on the calling program customizes itself for sorting,...
3
by: Adam J. Schaff | last post by:
Hello. I recently noticed that the Sort method of the .NET ArrayList class does not behave as I expected. I expect 'A' < '_' < 'a' (as per their ascii values) but what I got was the opposite....
19
by: Derek Martin | last post by:
Hi there, I have been playing with sorting my arraylist and having some troubles. Maybe just going about it wrong. My arraylist contains objects and one of the members of the object is 'name.' I...
0
by: Grant Wickman | last post by:
Our team has just fixed a really nasty problem that appears to be caused by an obscure bug in the sort method of Arraylist and daisy-chained webservice stubs. We've fixed the bug so I'll not...
48
by: Alex Chudnovsky | last post by:
I have come across with what appears to be a significant performance bug in ..NET 2.0 ArrayList.Sort method when compared with Array.Sort on the same data. Same data on the same CPU gets sorted a...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.