Comparator function (using vector pair section)

can you please explain me how do comparator function works??like when it returns true then what happens do swapping occurs or what??like in this section of vector pair we are using comparator function in which we are comparing the distance from origin and it returns true when first distance is less than the second one . so how do we get to know that sorting occurs in ascending or descending order.

hi @gulatigarvita08 if the compare functions looks like this
bool myComp(int a, int b)
{ return a < b; }
this will make your sorting in ascending order. If you return a > b this will sort in descending order.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.