Comparators order of comparing

whenever I insert a compare function in STL algorithms the comparisons are different…like if I put return ab to compare in ascending order…why is this so?
Does that depend on how internally c++ stl is designed or is there any generic rule of how these c++ stl algos are wriiten?

hello @kani001

it depends on internal implementation of datastructure , at which u r applying ur compare function.

for example ->

to sort the vector in ascending order->

we do  return  a < b; 


but if we use same comparator for priority queue 
then it will work as max heap (i.e on top u will get highest element )

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.