Regardless of whether this is the most efficient way to structure this sorting algorithm in Python (it's not), my understandings of indexing requirements/the nature of the built-in 'min' function are failing to account for the following error in the following code:
builtins.IndexError: list index out of range
#Create function to sort arrays with numeric entries in increasing order
arruns = arr #pool of unsorted array values, initially the same as 'arr'
indmin = 0 #initialize arbitrary value for indmin.
#indmin is the index of the minimum value of the entries in arruns
for i in range(0,len(arr)):
if i > 0: #after the first looping cycle
del arruns[indmin] #remove the entry that has been properly sorted
#from the pool of unsorted values.
while arr[i] != min(arruns):
indmin = arruns.index(min(arruns)) #get index of min value in arruns
arr[i] = arruns[indmin]
x = [1,0,5,4] #simple array to be sorted
print(x) #The expectation is: [0,1,4,5]
arruns are the same lists. You are removing items from the list, decreasing its size, but leaving max value of
i variable untouched.
arruns =  + arr
This will create new array for