This is an extract from a working quicksort implementation. However, it uses the first item as the pivot and I need it to be able to swap between using the first and last item. How would I go about doing this? (Changing pivot\_pointer = list[start] to pivot\_pointer = list[end] outputs unsorted data.)

Thanks

```
def recursive_split(list, start, end):
   if start < end:
       split = qsortpartition(list, start, end)
       recursive_split(list, start, split - 1)
       recursive_split(list, split + 1, end)

def qsortpartition(list, start, end):
    left_pointer = start + 1
    right_pointer = end
    pivot_pointer = list[start]

    while not pointers_converged:
        while left_pointer <= right_pointer and \
            list[left_pointer] >= pivot_pointer:

            left_pointer += 1

        while list[right_pointer] <= pivot_pointer and \
            right_pointer >= left_pointer:

            right_pointer -= 1

        if right_pointer < left_pointer:
            pointers_converged = True

        else:
            list = switch(list, left_pointer, right_pointer)

    list = switch(list, start, right_pointer)

    return right_pointer

```