mutable implementation for quicksort (with swapping)