func simpleSelectionSort(unsorted []int, n int) {
var key, temp int
for i:=0; i<n; i++ {
key = selectMiniKey(unsorted, n, i)
if key!=i {
temp = unsorted[i]
unsorted[i] = unsorted[key]
unsorted[key] = temp
}
}
}
func selectMiniKey(a []int, n int, i int) int {
k:=i
for j := i+1; j<n; j++ {
if a[k] > a[j] {
k = j
}
}
return k
}
转载于:https://blog.51cto.com/11317783/1978033