Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Ksort ¶
func Ksort(eachMap interface{}, eachFunc interface{})
以map的key(int\float\string)排序遍历map eachMap -> 待遍历的map eachFunc -> map遍历接收,入参应该符合map的key和value 需要对传入类型进行检查,不符合则直接panic提醒进行代码调整
// 使用: m := map[int]string{}
m[5] = "Hello World"
m[2] = "Hello World"
result := []string{} // 排序好装到切片里面,别装map,map装进去又变无序的了
Ksort(m, func(key int, value string) { // 这个类似于php的array_map(), 遍历把结果放到result中,要注意key value的数据类型与原map保持一致
result[key] = value
})
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.