Two sections. One sorted. One unsorted. Select the smallest/largest value in the unsorted section and place it at the end of the sorted section. Continue until no values are left in the unsorted section.
funcselectionSort(array:inout[Int])->[Int]{for i in0..< array.count-1{var indexOfSmallestValue = i
for j in i ..< array.count{
indexOfSmallestValue = array[j]< array[indexOfSmallestValue]? j : indexOfSmallestValue
}
array.swapAt(i, indexOfSmallestValue)}return array
}