In bubble sort we do
if (a[j] > a[j + 1])
{
swap(a[j], a[j + 1]);
}
in order to sort in increasing order
but in compare function we used
return a>b;
i m unable to understand please clear it
Comparators in sort
the compare function return true or false on the basis of comparison if the comparison returns true a is placed before b else otherwise
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.