Specify a quick sort algorithm in Python to sort the given array of numbers.
[9, 6, 5, 3, 4, 7, 4, 1]
def quick_sort(arr):
    if len(arr) <= 1:
        return arr
    pivot = arr[len(arr) // 2]
    left = [x for x in arr if x < pivot]
    mid = [x for x in arr if x == pivot]
    right = [x for x in arr if x > pivot]
    return quick_sort(left) + mid + quick_sort(right)

print(quick_sort([9, 6, 5, 3, 4, 7, 4, 1]))