implements selection sort