Completed QuickSort implementation with median of three pivot rule.