Help on array

Hi, I want to sort an array which contains Strings (sort according to alphabetical order...)

after i sort the array...i want to read it at it's original order too...

that mean's i want to have 2 set of array.....1 with the original order...1 with the sorted order..

how do i do that?

let's say i have a container class Club with an array of Names(type String), and a client class...

with a Club object memberList.how do i do that?

thank you.

[494 byte] By [maykawaii] at [2007-9-30 6:46:02]
# 1

> that mean's i want to have 2 set of array.....1 with

> the original order...1 with the sorted order..

OK, how about

ArrayList origArray = ... whatever ...;

ArrayList sorted = new ArrayList(origArray);

Collections.sort(sorted);

Now, origArray still has your data in the original order, sorted has it in the sorted order. Note: both are pointing to the same elements.

shankar.unni at 2007-7-1 21:54:05 > top of Java-index,Administration Tools,Sun Connection...
# 2

Hi,

You can use "System.ArrayCopy" function to create a second array. (Now you have two different set of Arrays)

After that use the following code:

Arrays.sort(strArray);

Where Arrays is your inbuilt class with sort as static function and strArray is the name of the array that you want to sort.

I hope this helps :)

Parvesh

sharma_parvesh at 2007-7-1 21:54:05 > top of Java-index,Administration Tools,Sun Connection...