Completed selection sort