Selection sort algorithm implementation.