definitions for quicksort functions