How would you sort 5 parallel arrays in ascending order?
How would you sort 5 parallel arrays in ascending order?
Last edited by Brian Swisher; 04-03-2012 at 11:13 PM.
I would prefer an array of structs as it is easier to handle and reason about, plus it easily allows for the use of standard algorithms like std::sort.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
If I understand what you're talking about right, you basically want to create a sixth temporary array that tracks the position of where all the original elements are. Then sort whichever array you're basing the sort off of. As you do this, keep up with the changes in the temporary array. Once you're done sorting the first, use the sixth to sort two through five.