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.

26 lines
425 B

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