Hello sir,
sir apne bola ki agar asending order main agar humko sorting karni hai to humara jo comparator function hoga usme hum ab iska use karege leking
suppose humare elements [1,2,3] honge
or hame desending order main sorting karni hai to humara
comparator fun
bool compare(int a,int b)
{
cout<<“compare “<<a<<” “<<b<<” “<<bool(a>b)<<”\n”;
return a>b;
}
agar isne return true kiya to hum swaping karenge and false kiya to no swaping
[1,2,3]
1>2 ye condition false hai to vo swaping kaise karega ?