Comparator function

how is the condition a <b in the compare function ensuring that the elements are being sorted in the decreasing order… pls explain with example

hello @vector.9974

if our comprator declaration is like this->
bool cmp(int a,int b)

then a comes first in array and then b.

now to decide the order between them we use < or > signs.

if we are using < i,e
return a<b then we are saying that element that comes first must be smaller than elemnt that comes later (thats why output will be sorted in ascending order).

if we are using >
return a> b then we are saying that element that comes first must be greater than element that comes later (thats why output will be sorted in descending order).