sorting of queues