1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-08 14:42:27 +08:00

feat: add SortbyKeys for map

This commit is contained in:
dudaodong
2024-08-23 11:21:29 +08:00
parent 30971c1aab
commit 3e8c3bd396
5 changed files with 151 additions and 0 deletions

View File

@@ -540,3 +540,19 @@ func ExampleGetOrSet() {
// a
// b
}
func ExampleSortByKeys() {
m := map[int]string{
3: "c",
1: "a",
4: "d",
2: "b",
}
result := SortByKeys(m)
fmt.Println(result)
// Output:
// map[1:a 2:b 3:c 4:d]
}