Finally a correct implementation for QuickSort