Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
29 lines (24 sloc) 436 Bytes
package main
import (
"fmt"
"sort"
)
func main() {
items := make(map[int]string)
for i := 0; i < 10; i++ {
items[i] = fmt.Sprintf("This is item %d", i)
}
// Generates keys map.
keys := make([]int, len(items))
for k := range items {
keys[k] = k
}
sort.Ints(keys)
// Iterates over items map, using sorted keys.
for _, k := range keys {
performItem(items[k])
}
}
func performItem(item string) {
fmt.Println(item)
}
You can’t perform that action at this time.