Answer
procedure selectionsort $( a_1, a_2, a_3, ... a_n:$ A list of integers to be sorted$)$
for $i:=1$ to $n-1$
$\space\space\space$min$:=i$
$\space\space\space$for $j:=i+1$ to $n$
$\space\space\space$$\space\space\space$ if $a_j
Work Step by Step
This algorithm attempts to sort a list using the selection sort. It does this by looping $n-1$ times over the list and each time, selecting the smallest value and placing it at the appropriate position. After locating the smallest value, it gets swapped with whatever is in it's appropriate position.
Notice how we simplified the logic by defining a swap function rather than making the sorting algorithm look bulky.