I have a vector L containing vectors with 2 doubles each. I want to sort the vectors in L by their first element.
vector<vector<double>> L;
I tried to use the std::sort algorithm with a self-written compare function as follows:
bool compare(const vector<double> &v1, const vector<double> &v2)
{
return v1[0] < v2[0];
}
void out_2d_vecotr_as_value_pairs(vector<vector<double>> &L)
{
L = sort(L.begin(), L.end(), compare);
...
}
But I get this error I don't understand for the line calling the sort() function:
projet.cc:234:38: error: no match for ‘operator=’ (operand types are ‘std::vector<std::vector<double> >’ and ‘void’)
Thanks for your help
Aucun commentaire:
Enregistrer un commentaire