问题描述
我有一片uint64( sort包有一个函数 我该怎么办?我可以输入全部分片吗? 谢谢 版本1.8,您可以使用更简单的函数。在你的情况下,它将如下所示: 这样可以避免必须定义任何类型只是为了排序。 I'm writing Go application using Go 1.7rc3. I have a slice of uint64 ( the sort package has a function what do I do? can I type cast the all slice ? thanks As of version 1.8, you can use the simpler function This avoids having to define any type just for the sorting. 这篇关于排序uint64切片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! var dirRange [] uint64 $
sort.Ints()
但它需要 [] int
,并且我有 [] uint64
。
sort.Slice(dirRange,func(i,j int)bool {return dirRange [i]< dirRange [j]})
var dirRange []uint64
) that I want to sort.sort.Ints()
but it requires []int
and I have []uint64
. sort.Slice
. In your case, it would be something like the following:sort.Slice(dirRange, func(i, j int) bool { return dirRange[i] < dirRange[j] })