Sorting using selection sort