fixed selection sort method