Quick sort method from the book