How greater<int> produces min heap?

As I checked in sort function in STL, the “greater()” produces the results in descending order. while here in priority_queue, we are using greater for produced min heap (which means asceding order). So, I am a little bit confused on how greater is working in priority queue?

@subham221 both are different data structures and hence their functionalities differ. Sort function is for linear data structures like arrays, strings, vector. As you know priority queue is a unique type of data structure and has a unique implementation. If you wish to learn the inner workings of the STL in detail, you can refer to the documentation.

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.