Comparators _understanding the working

Hi sir, why do you pass compare function as a parameter while we can just calling it like any regular function??

hello @mzk1994

by default sort function order the elemnts in ascending order.
but if we want to order them in some different order then comparators are needed .
inside comparators we write how we want to order any two entries in our container .

u can call but then it will work only for two numbers.

we have array which can have so many numbers .

read this documentation of sort function for better clarity->
http://www.cplusplus.com/reference/algorithm/sort/

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.