Sort Priority Queue Java

Please tell me - How to sort priority queue of objects in java?

What is a priority queue?
Priority queue is essentially a heap, with max element at top(in C++, probably it is same is java).
Now if you’re are using it in some question, why do you need to sort it?
And if you need to sort it, use some other DS rather than priority queue.
If you want a min priority queue, insert negetive elements, and its a cool hack to extract min element from top of priority queue.

2 Likes

As @neilit1992 already explained about priority queue, If you can elaborate your question then we might help better, like what you need to sort inside your object.

2 Likes
//