Quick sort refinement and 3way quick sort impl