Why answer is different after changing return condition in compare function from xy>yx to yx >xy??
Biggest No. Problem
Hello @Alfred this is because you have changes your whole comparator function.
you are now sorting in the descending order ,wheread previously you were sorting in the ascending order.
that is the diiference:
Happy Learning!!
Can you tell me the diiference betweeb return a>b and return b>a
according to me both should be same
@Alfred in a>b the compare fucntion will return true if the element a is greater then b whereas in contrary b>a will return true if b is greater then a.
if you still have any doubt you can ask here:
Happy Learning!!
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.