Q:

My function returns an empty array, while the sort function works

My function works perfectly if I write
array = sort(array)

but when I just use the function on my array
sort(array)

the return is an empty array. This is probably a stupid mistake but I just can't find it. I return the res in the function?
def sort(array):
    res = []
    for i in range(len(array)):
        minimum = array[0]
        for j in range(len(array)):
            if array[j] < minimum:
                minimum = array[j]
        array.remove(minimum)
        res.append(minimum)
    return res

array = [9, 1, 5, 7, 3, 8, 4, 6, 2, 0] 
sort(array) => array returns empty here
print(array)

A:

Instead of returning the result, you need to copy its elements into the original list. So replace:
return res

with:
array[:] = res

Assigning to a slice inserts the list into that portion of the target list. The slice [:] refers to the entire list.

