Implemented quicksort for median