quick sort for queue