do you have some efficient routine for returning array with indices for sorted elements in a array? I think that some convenient way exists using stl vector. Do you have alr
Adding to @Konrad answer:
If for some reason you are not able to use C++11, then you can use boost::phoenix to simulate it like
#include
#include
#include
#include
template
std::vector ordered(std::vector const& values)
{
using namespace boost::phoenix;
using namespace boost::phoenix::arg_names;
std::vector indices(values.size());
int i = 0;
std::transform(values.begin(), values.end(), indices.begin(), ref(i)++);
std::sort(indices.begin(), indices.end(), ref(values)[arg1] < ref(values)[arg2]);
return indices;
}