lundi 21 février 2022

Understanding a custom sort comparator - How to know what a true return means

I came across this sort comparator for a vector std::vector<foo>

bool comp(foo& x, foo& y) 
{
    return x.a < y.a;
}

Can someone explain what this does ? Does this mean that if a function returns false. foo x will be on the top and y at the bottom. Basically I am trying to understand is how do i know which element gets to be on the top ?

Aucun commentaire:

Enregistrer un commentaire