Is there some reason you can't combine the track titles and track numbers into a single struct or class, so that they sort together, instead of using two parallel arrays?
Originally Posted by greatunknown
Failing that, you'll need to modify the items in the track title array to include an index number:
Then, you initialize the indicies:
std::vector< IndexedTrackTitle > trackTitles;
Then sort the trackTitles array. Now, the indicies will tell you the corresponding track number for a given entry in the trackTitles array:
for( int n = 0; n < trackTitles.size(); ++n )
trackTitles[ n ].index = n;
Notice how it's absolutely necessary to store some kind of extra data with the track titles. If you're going to do that, you might as well just store the track number directly, and avoid this mess completely.
std::string number = trackNumbers[ trackTitles[ n ].index ]