Why does using a comparator function in sort make this program much slow ?

This gives TLE

bool mod(int a,int b){
return a>=b;
}
sort(a,a+n,mod);

Whereas , this runs in 0.06 sec , why ? Does using a cmp fn make sort too slow or should i use pass by reference or something like that ?

sort(a , a+n , greater());

Only difference between the codes is the use of comparator. What can be the reason for slowdown ?

= and <= is invalid in comparator functions. Change that into > and you shall make it. For every comparator function cmp(a, a) = 0 is a must

I’m not sure , what do we do then if we need stable sorting , and why did the code run if the comparator was invalid ? Thanks.