golang ----map按key排序-CSDN博客

网站介绍:文章浏览阅读1.8k次。实现map遍历有序1. key有序思路:对key排序,再遍历key输出value代码如下:既可以从小到大排序,也可以从大到小排序package mainimport ( "fmt" "sort")func main() { // To create a map as input m := make(map[int]string) m[1] = "a" m[2] = ..._golang map key sort