LinkedHashMap provides map with order of elements.
$ go get -u github.com/howood/linkedhashmap
// Create new
lMap := NewLinkedHashMap()
// Set map data
lMap.Put("tokyo", 3)
lMap.Put("yokohama", 23)
lMap.Put("kyoto", 44)
lMap.Put("sapporo", 65)
lMap.Put("fukuoka", 76)
// Get map data
val := lMap.Get("sendai") // interface{}
// Remove map data
lMap.Remove("sapporo")
// Get all keys and values
keys := lMap.Keys()
values := lMap.Values()
// Itretor
for lm := range lMap.Iter() {
log.Printf("%v: %v", lm.Key, lm.Value)
}
// Sort with key
lMap.SortKeyAsc()
lMap.SortKeyDesc()
// Sort with value
lMap.SortValueAsc()
lMap.SortValueDesc()