Create a method that sorts an array of integers using quicksort.
Implement quicksort(nums), sorting nums in place and returning the same list. Handle empty arrays, duplicate values, negative integers, and already sorted input. Do not call the built-in sorting functions.
def quicksort(nums):