feat: add SortbyKeys for map

This commit is contained in:
dudaodong committed 2024-08-23 11:21:29 +08:00
1 parent 30971c1aab
commit 3e8c3bd396
5 files changed
+151

No files matched your search

+16
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]
}