Go 排序
1)、冒泡排序
package main import ( "fmt" "log" ) func main() { sli := []int{2, 4, 9, 23, 90, -20, 3, 5, 21, -7, 32, 9, 14, 6} if len(sli) == 0 || len(sli) < 2 { log.Fatal("too few arguments") } for j := 0; j < len(sli)-2; j++ { for i := 0; i < len(sli)-1; i++ { if sli[i] > sli[i+1] { sli[i], sli[i+1] = sli[i+1], sli[i] } } } fmt.Println(sli) }