Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

STL priority queue in increasing order [duplicate]

I need to store numbers in a queue in increasing order.
I used priority queue which stores higher value first, that is in decreasing order.

priority_queue<int>q;

Is it possible to order them increasing ?
What can i do to make the data order to be increasing ?

like image 569
Pablo Avatar asked Dec 05 '22 22:12

Pablo


1 Answers

To store value in increasing order you just need to change the declaration of the priority queue :

priority_queue<int, vector<int>, greater<int> >q;
like image 142
Ali Akber Avatar answered Dec 21 '22 13:12

Ali Akber