I am very new to c++ and can't find a way to keep track of my vector indexing after sorting an vector.
So far I have:
static bool sortlowtohighinternal(double u, double v) //internal use in sortlowtohigh
{
return u < v;
}
vector<double> sortlowtohigh(vector<double> v){
sort(v.begin(), v.end(), sortlowtohighinternal);
return v;
}
which will sort the vector<double>
from low to high but it also reindexes the vector. Is it possible to get something like:
Input Vector: {1.0, 3.0, 2.0}
Output Sorted Vector: {1.0, 2.0, 3.0}
Output Of Indexes from Input Vector: {1, 3, 2}