quick sort with median of 3