performing selection sort