Understanding the quick sort algorithm