Package sort中Ints的用法

func Ints

func Ints(a []int)

Ints sorts a slice of ints in increasing order

例子:

package main

import (
	"fmt"
	"sort"
)

func main() {
	s := []int{5, 2, 6, 3, 1, 4} // unsorted
	sort.Ints(s)
	fmt.Println(s)
}
posted @ 2020-11-11 13:46  TR_Goldfish  阅读(560)  评论(0编辑  收藏  举报