Write a quick sorting algorithm and explain the key concepts behind it.
Implement quick_sort(nums) to sort an array of integers in ascending order and return the sorted array. Use the quicksort algorithm rather than Python's built-in sorting functions. The implementation may modify nums in place.
def quick_sort(nums):