Horje
 comparator for sorting vector of struct in c++ Code Example
comparator for sorting vector of struct in c++
struct point{
    int weight, position, id;
};
// . . . . . .
// your code
// for sorting using weight 
sort(points.begin(), points.end(), [] (point a, point b){
return a.weight < b.weight;
});


// for sorting using positions
sort(points.begin(), points.end(), [] (point a, point b){
return a.position < b.position;
});




Cpp

Related
c++ return value of set insert Code Example c++ return value of set insert Code Example
how to sort a string in c++ Code Example how to sort a string in c++ Code Example
sqrt cpp Code Example sqrt cpp Code Example
how to declare 1-D array in C/C++ Code Example how to declare 1-D array in C/C++ Code Example
arduino notone Code Example arduino notone Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
12