You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
509 B

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