sort.Ints is a convenient function to sort a couple of ints. Generally you need to implement the sort.Interface interface if you want to sort something and sort.Reverse just returns a different implementation of that interface that redefines the Less
method.
Luckily the sort package contains a predefined type called IntSlice that implements sort.Interface:
keys := []int{3, 2, 8, 1}
sort.Sort(sort.Reverse(sort.IntSlice(keys)))
fmt.Println(keys)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…