Selection sort is a sorting algorithm

we compare the value in the first position with the value in the second position if the value in the second position is smaller then we swap the two values, otherwise we do nothing, assuring that the first position holds the smaller of both.
then we compare the value in the first position again with the value in the third position and make the same with the fourth and fifth until the last position in the array
after finishing these steps we’d have the smallest value in the first position
we will repeat these steps with the second position comparing it with the third and fourth until the end which would result that the second smallest value in the second position
we will repeat this again and again with every position until the end.
(more…)