quicksort-based selection code

expected running time is linear