argos/printSortedMapStringInt.go
printSortedMapStringInt.goRaw
1package main
2
3import (
4 "fmt"
5 "sort"
6 "strconv"
7)
8
9func printSortedMapStringInt(m map[string]int, threshold int) map[int][]string {
10 total := len(m)
11 fmt.Println("total: " + strconv.Itoa(total))
12 n := map[int][]string{}
13 var a []int
14 for k, v := range m {
15 if v > threshold {
16 n[v] = append(n[v], k)
17 }
18 }
19 for k := range n {
20 a = append(a, k)
21 }
22 sort.Sort(sort.Reverse(sort.IntSlice(a)))
23 for _, k := range a {
24 for _, s := range n[k] {
25 //fmt.Printf("%d (%d)- %s,\n", k, tantPerCent, s)
26 fmt.Println(strconv.Itoa(k) + " - " + s)
27 }
28 }
29 return n
30}