Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

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;
});
 
PREVIOUS NEXT
Tagged: #sorting #comparator
ADD COMMENT
Topic
Name
8+8 =