I am begginner in java and queues.I have one queue which contains only integers. In my code, I am doing operations inside a for loop with a few queues. Is there any way to sort the queue without using another queue? I mean i want to use only the same queue. The queue like this:
Queue q = new Queue(10);
q.enqueue(89);
q.enqueue(17);
q.enqueue(25);
q.enqueue(5);
q.enqueue(39);
q.enqueue(96);
I was able to do it with two queues in the another code. But since it is in a for loop in my code and it is assigned before a queue for loop, I could not use that method.