sortkit

package
v0.10.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 21, 2023 License: MIT Imports: 3 Imported by: 0

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
    })

func SliceSort

func SliceSort()

Int 切片升序

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL