I know comparators for sorting ,I know that comp(x,y) should return true to get order ..,x ,....,y.. in a vector.
bool comp(int x,int y){
return occurences[x]<occurences[y];
}
sort(data.begin(),data.end(),cmp); according to x will followed by y in vector (...x..y..)
But recently I get to know about same thing using operator overloading regarding which i have some doubts.
struct Edge{
int u,v,weight;
bool operator < (Edge const& other){
return weight < other.weight;
}
}
1) will it going to work in the same way?Like here if current edge weight
2)And which will come first ,I mean above in above format comp(x,y) return true then x will come first But what is the criteria here because it seems that we are passing only argument here in the operator overloading function. Like if we compare Edge1(weight=40) < Edge2(weight=60) then which will come first and why?