Sort with two queues