Why there is a need to pass comparator function even if we are calling it at the time of comparasion in the if statement.
Passing comparator function
hi @sukritbansal01 the address of compare function is being passed to keep the syntax similar to how you call the STL sort function and the comparator.
Syntax for inbuilt sort function:
sort(a, a+n, cmp);
1 Like