dongtaihui5131
2019-03-26 14:51
浏览 441
已采纳

golang按第一个元素对切片进行切片

i'm trying to do sorting for my slice child's (inside a slice), my slice is created from

var s [][]int64
s = append(s, []int64{2, 60, 55, 5})
s = append(s, []int64{4, 45, 35, 10})
s = append(s, []int64{1, 200, 160, 40})
fmt.Println(s) # [[2 60 55 5] [4 45 35 10] [1 200 160 40]]

how to sort it's value by first element to become :

[[1 200 160 40] [2 60 55 5] [4 45 35 10]]

图片转代码服务由CSDN问答提供 功能建议

我正在尝试对切片儿童(切片内)的切片,切片是从

  var s [] [] int64 
s = append(s,[] int64 {2,60,55,5})
s = append(s,[] int64 {  4,45,35,10})
s = append(s,[] int64 {1,200,160,40})
fmt.Println(s)#[[2 60 55 5] [4 45 35 10]  [1 200 160 40]] 
   
 
 

如何按第一个元素将其值排序为:

  [  [1 200 160 40] [2 60 55 5] [4 45 35 10]] 
   
 
  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

相关推荐 更多相似问题