go sort排序
作者:互联网
package main import ( "fmt" "sort" ) func main() { str := []string{"我", "是", "d", "b","c", } sort.Strings(str) fmt.Println(str) ints := []int{5,4,3,2,1} sort.Ints(ints) fmt.Println(ints) floats := []float64{1.1, 0.4, 9.3, 2.1} sort.Float64s(floats) fmt.Println(floats) uints := []uint8{4,2,1,5,5} sort.Slice(uints, func(i, j int) bool { return uints[i] < uints[j] }) fmt.Println(uints) }
标签:sort,uints,fmt,Println,ints,go,排序,floats 来源: https://www.cnblogs.com/zhangjian0092/p/12559475.html