added sorting a queue in place