View Single Post
Join Date: Jul 2005
Posts: 1,671
Reputation: Lerner is a name known to all Lerner is a name known to all Lerner is a name known to all Lerner is a name known to all Lerner is a name known to all Lerner is a name known to all 
Solved Threads: 261
Lerner Lerner is offline Offline
Posting Virtuoso

Re: Finding Positon of characters

 
0
  #3
Dec 2nd, 2008
That's a better description of the project, but you could have posted it in your original thread.

As I see it the trick is to keep track of the original element indexes after you have sorted the array. I can think of two ways to do that.

First, copy the original array, sort the copied array, then loop through the original array to find the index of the element with the same value as the current element in the sorted array and place it in a third array containing the indexes in the original . Sort of a mapping of values in the sorted array to indexes in the original array.

Second option, create a struct holding the value and the index of each element in the original array, make an array of struct and sort it based on value, then display it using the indexes stored in each struct object.
Klatu Barada Nikto
Reply With Quote