# O(n**2) Time | O(1) spacedef selectionSort(array): currentIdx =0#starting position of the unsorted arraywhile currentIdx <len(array) -1: smallestIdx = currentIdxfor i inrange(currentIdx+1,len(array)):if array[smallestIdx] > array[i]: # Find the smallest number in the array smallestIdx = i swap(currentIdx,smallestIdx,array) # Get the smallest number to the start of the array currentIdx +=1# Shift the position of the unsorted arrayreturn arraydef swap(i,j,array): # Function to swap the numbers in the array array[i],array[j] = array[j],array[i]