Comparator function

I was using comparator function and I am not able to understand how this works. Why is it comparing 2 and 1 first? It should be 1 and 2 and how the iteration is really taking place??

hi @div_yanshu07 dont worry about the order of the comparison, the inbuilt sort function uses a hybrid searching algorithm. All elements shall be compared eventually, and the compare function provides a basis of comparison.

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.