changed quicksort to allow for descending sort and modified beam search accordingly