hi I don't understand how this code work. Explain me pls. Thank you.
#how this function finds the smallest element of the array.
def findSmallest(arr):
smallest = arr[0]
smallest_index = 0
for i in range(1, len(arr)):
if arr[i] < smallest: #--> why this is here and what does it mean?
smallest_index = i
smallest = arr[i]
return smallest_index
def selectionSort(arr):
newArr = []
for i in range(len(arr)):
smallest = findSmallest(arr)
newArr.append(arr.pop(smallest))
return newArr
print(selectionSort([5, 3, 6, 2, 10]))
how "findSmallest" function finds the smallest element of the array?