I have a 2D array of an encryption String as seen below..
C H R I S T --> the header
D F F G A D
D A X D A D
G A Z Z Z Z
I have to sort the header ascending and form another array as seen below..
C H I R S T --> the header
D F G F A D
D A D X A D
G A Z Z Z Z
I have been trying to find a proper logic to solve this.. I was thinking to sort the header first then grab the new index position of every alphabet in the header then move the elements of the header to the new index position.. but i couldn't apply it properly.. Any idea how to solve this? Thanks before..
Wow.. Thanks a lot, PhHein! It works perfectly..!
You're welcome. Sometimes it helps to know the APIs ;)
EDIT: Don't forget to mark the thread as solved.
I forget to look at the rows below the header, it looks the same.. Do you have any suggestion to change those also? So when the header is sorted, the rows below changes its places to the same index as its header.. Thanks.. :)
Ooh, that's a little detail that was unclear in your original querstion.
You should also specify how to handle duplicates in the header, e.g. it's C H A A B?
Basically you have to provide a mapping: index 0 goes to index 3, index 1 goes to index 4 etc.
Yea, but I already eliminate the duplicates in some part of the program..
Hmm.. Any suggestion how to make the mapping? Because the the header can be anything that user input.. Thanks... :)
If it's a user input, how do you handle an input of: A B A C A?
It will be ABC and it will make as many rows as it needs to contain all the String and put Z's in extra elements. So it wont return an exception..
Ok, it works. Use an int  to store the new ordering, i.e [0, 1, 3, 2, 4, 5]. Then reorder the rows if the 2D char.
EDIT: I know that I'm cryptic, but I want you to find a solution yourself.
Yea, I need the breakthrough from this problem.. Thanks for your help..:)
OO concepts would help..try storing the indexes as attributes..