iterative selection sort