Simplify selection sort algorithm