Selection sort in Python
    Table of Contents hide ►
    
  
  
Selection sort runining time is very high as \(O(N^2)\).

Example code:
def findSmallest(a):
    smallest=a[0]
    index = 0
    for i in range(1, len(a)):
        if smallest > a[i]:
            smallest = a[i]
            index = i
    return index
def selection_sort(a):
    sorted_array = []
    for i in range(len(a)):
        smallest_position = findSmallest(a) # O(nxn)
        sorted_array.append(a.pop(smallest_position))
    return sorted_array
# Test
print(selection_sort([5,3,9,4,1,6,20]))