package main import "fmt" func SelectSort(data []int) {
length := len(data)
for i := 0; i < length; i++ {
tmp := data[i]
flag := i
for j := i + 1; j < length; j++ {
if data[j] < tmp {
tmp = data[j]
flag = j
}
} if flag != i {
data[flag] = data[i]
data[i] = tmp
}
fmt.Println(data) //为了看具体排序的过程 }
} func main() {
data := []int{44, 38, 65, 97, 76, 14, 27, 48}
SelectSort(data)
fmt.Println(data)
}