Sort two queues