mirror of
https://github.com/duke-git/lancet.git
synced 2026-11-16 05:12:11 +08:00
feat: add SortbyKeys for map
This commit is contained in:
1 parent
30971c1aab
commit
3e8c3bd396
5 files changed
+151
No files matched your search
@@ -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]
|
||||
}
|
||||
Reference in new issue
Block a user