refactored selection sort
refactored selection sort using 2 for loops