# Programmer: Sriram Pemmaraju # Date: 3/7/2012 def swap(L, i, j): '''Swaps the elements in the list L at positions i and j''' temp = L[i] L[i] = L[j] L[j] = temp def selectionSort(L): '''Sorts a list of elements in ascending order by repeatedly selecting the minimum element from the rest of the list and bringing it to the front.''' n = len(L) for i in range(n): m = min(L[i:]) j = i + L[i:].index(m) swap(L, i, j) return L