I have a vector of objects whose elements I want to access in a sequence other than originally stored. My initial thought was to create an array of pointers, one for each array object, and move the pointer values to the desired order (so the underlying array doesn't need to change).
The vector iterator seems similar to an array of pointers, but I couldn't determine if they can be repointed.
Is there a customary way to do this?
ETA: @doug's comment below sent my mind down another path and I think I was overcomplicating the task. Each object in the array has an attribute that determines the order I want to consume another attribute. Based on doug's suggestion, I could traverse the array and write out two new arrays (one for each attribute) and do a vector of pairs sort. Consistent with @Ted Lyngmo's thought, maybe I could traverse the array and write out a single new array of structures comprised of the two attributes and then do a std::sort.
ETA 2: In case it matters, the vector of objects is generated by an external library and the attributes are only exposed through method calls.