2021
06-03
06-03
golang 实现对Map进行键值自定义排序
看代码吧~//自定义结构体,用来自定义排序typeRecentlyUpdateListMapSorter[]map[string]interface{}//根据MapSorter.Keys进行倒序排序func(ms*RecentlyUpdateListMapSorter)SortReverse(){sort.Sort(sort.Reverse(ms))}//自定义排序方法(Len(),Less(),Swap())func(ms*RecentlyUpdateListMapSorter)Len()int{returnlen(*ms)}func(ms*RecentlyUpdateListMapSorter)Less(i,jint)bool{t1,_:=time.Parse(tim...
继续阅读 >