I'm following the pseudocode as given as a part of an excercise in CLRS.
Consider sorting \$n\$ numbers stored in array \$A\$ by first finding the smallest element of \$A\$ and exchanging it with the element in \$A\$. Then find the second smallest element of \$A\$, and exchange it with \$A\$. Continue in this manner for the first \$n-1\$ elements of \$A\$.
a = [99, 31, 41, 59, 26, 42, 58] for i in range(0, len(a)): min = a[i] for j in range(i, len(a)): if a[j] < min: min = a[j] a[j] = a[i] a[i] = min