package main
import (
"sort"
"fmt"
)
type intSlice []int
func (p intSlice) Len() int { return len(p) }
func (p intSlice) Less(i, j int) bool { return p[i] < p[j] }
func (p intSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
func main() {
dd := make(intSlice,0)
dd = append(dd,1,3,2,5)
sort.Sort(sort.Reverse(dd))
fmt.Println(dd)
}
Golang切片降序排列
猜你喜欢
转载自blog.csdn.net/skh2015java/article/details/81282289
今日推荐
周排行