fix bug in QUICKSORT when q+1 > r