title: Sorting a Map of Structs - GOLANG
body: <p>I have a map of structs that I am populating by streaming data to a Go program.  The way the map is updated is similar to the example below.  </p>
  
  <p>Once I have this map of structs populated, what is the best (or good) way to sort this map by the values of the <code>count</code> field in the struct?  </p>
  
  <pre><code>package main
  
  type data struct {
      count int64
  }
  
  func main() {
      m := make(map[string]data)
      m["x"] = data{0, 0}
      if xx, ok := m["x"]; ok {
          xx.count = 2
          m["x"] = xx
      } else {
          panic("X isn't in the map")
      }
  }
  </code></pre>
  
  <p>This example can be run here: <a href="http://play.golang.org/p/OawL6QIXuO">http://play.golang.org/p/OawL6QIXuO</a> </p>