sorting _ golang
Go's sort package implements sorting for builtins and user-defined types. We'll look at sorting for builtins first
package main import ( "fmt" "sort" ) func main() { strs := []string{"c", "a", "b"} sort.Strings(strs) fmt.Println("Strings:", strs) ints := []int{7, 2, 4} sort.Ints(ints) fmt.Println("Ints: ", ints) s := sort.IntsAreSorted(ints) fmt.Println("Sorted: ", s) }
Strings: [a b c] Ints: [2 4 7] Sorted: true
总结 :
1 : ....
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。