Let's say we have a kit similar to the following: {12, 10, 4, 5, 7}
I would like to preserve the order of the collection so that the indices remain consistent but cross the collection in sorted order, for example {12, 10, 7, 5, 4}.
What I thought was to make another set of pointers to elements, and then sort the pointers.
What are your thoughts? Does such an algorithm already implemented in C ++?
Edit: In my case, I have vector<vector<double>>, and I would like to traverse the collection of the outer vector in non-decreasing order based on the sum of the inner vectors.
Jared source
share