I'm utterly confused as to what you're trying to do. Why do you need two arrays ? Or you don't need them, but in your solution you felt you needed both of them ?
Is it that you have the actual data in one, and their positions in the other one ? Is that the requirement of the problem, or is there any other reason why you want the two arrays ?
Re sorting objects, normally, I guess you'd just overload a generic sort function, with a separate function for each of your object types.
edit: a "simple" method, IF I understand correctly what you want (which I wouldn't bet money on), would be:
1st array holds the elements you want sorted, 2nd array holds their positions (or pointers to them, or whatever you want).
Whatever operation you do on the first array, do on the second array, as well. So, for example, let's say element 1 in array1 goes to position 3. Then you write 3 in element 1 in your second array.
Or, say your sorting algorithm exchanges elements 3 and 6 in array1. Exchange the values of elements 3 and 6 from the second array.
Does this make sense ?
Bookmarks