Horje
sorting using comparator in c++ Code Example
sorting using comparator 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
Get handle in C++ Code Example Get handle in C++ Code Example
c++ erase last element of set Code Example c++ erase last element of set Code Example
c++ how to make a negative float positive Code Example c++ how to make a negative float positive Code Example
platform io change baud rate Code Example platform io change baud rate Code Example
 comparator for sorting vector of struct in c++ Code Example comparator for sorting vector of struct in c++ Code Example

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