Go Example--排序

时间:2021-01-05 00:12:36
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(s)
}