I am trying to implement a sorting algorithm that will find the maximum and minimum elements in an array and then swap them with the last and first elements of the array, respectively. The algorithm will then shrink the array by two elements (the first and last elements, that have been placed in sorted position) and then perform the same operation repeatedly on the subarrays until the array is completely sorted.

I can't however seem to get it to function, and I'm not sure why. There are no errors of any kind, but the array is left completely unchanged after running the function. Here is what I have:

```
def novel_sort(arr, left, right):
    if left < right:
        min_index = left
        max_index = left
        for i in range(left, right+1):
            if arr[i] < arr[min_index]:
                min_index = i
            if arr[i] > arr[max_index]:
                max_index = i
        arr[left], arr[min_index] = arr[min_index], arr[left]
        arr[right], arr[max_index] = arr[max_index], arr[right]
        novel_sort(arr, left + 1, right - 1)

```

Input

```
l = [235, 25, 123, 1]
novel_sort(l, 0, len(l) - 1)
print(l)

```

Expected output

```
[1, 25, 123, 235]

```

Observed Output

```
[235, 25, 123, 1]

```

If I change the `for` loop to `for i in range(left, right)` then every element of the array will be sorted except for the last element (`[1, 123, 235, 25]`). I've tried following along by iteration, but I still cannot seem to figure out what is happening.