-
-
Notifications
You must be signed in to change notification settings - Fork 54
Expand file tree
/
Copy pathmain.go
More file actions
28 lines (24 loc) · 519 Bytes
/
Copy pathmain.go
File metadata and controls
28 lines (24 loc) · 519 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package main
import (
"fmt"
"maps"
"slices"
)
func main() {
numbers := map[string]int{
"one": 1,
"two": 2,
"three": 3,
"four": 4,
"five": 5,
}
fmt.Printf("numbers = %v\n", numbers)
// maps.Values
fmt.Printf("\nslices.Sorted(maps.Values(numbers))\n")
sortedValues := slices.Sorted(maps.Values(numbers))
fmt.Printf("\t%v\n", sortedValues)
// maps.Keys
fmt.Printf("\nslices.Sorted(maps.Keys(numbers))\n")
sortedKeys := slices.Sorted(maps.Keys(numbers))
fmt.Printf("\t%q\n", sortedKeys)
}