map
map[string]Hit

package main


import (

  "fmt"

  "sort"

)


type Hit struct {

  Key  string  `json:"key"`

  Data []Field `json:"data"`

}


type Field struct {

  Value string `json:"value"`

}


func main() {

  var mapOfHits = getSomeHits()

  var sortedHits = sortHits(mapOfHits)

  

  for _, h := range sortedHits {

    fmt.Println(h.Key)

  }


}


func getSomeHits() map[string]Hit {

  return make(map[string]Hit, 0)

}


func sortHits(m map[string]Hit) []Hit {

  keys := make([]string, 0, len(m))

  sorted := make([]Hit, 0, len(m))

  

  for k := range m {

    keys = append(keys, k)

  }


  sort.Strings(keys)


  for _, k := range keys {

    sorted = append(sorted, m[k])

  }


  return sorted

}