Due to the current user's lack of knowledge of the blockchain, coupled with the shortage of professionals in the blockchain and the lure of high salary, the market has spawned a number of blockchain training institutions. Brother Yun Jong, president of the Blockchain training Institute, says consumers need to be careful to differentiate themselves from the chain of training in the blockchain market.
The go language is optimized for programming multi-processor system applications, with go-compiled programs that are comparable to C or C + + code, and are more secure and support parallel processes.
Write code to find the need to sort Map[int64]int64, Golang in the sort package to solve the problem, the following is from the Internet to find 2 examples, Memo.
Example one:
Package Main
Import (
"FMT"
"Sort"
)
Func Main ()
M: = map[string]string{"B": "All", "Z": "123123", "X": "SDF", "a": "12"}
mk: = make ([]string, Len (m))
I: = 0
For k, _: = Range m {
Mk[i] = k
i++
}
Sort. Sortstrings (MK)
Fmt. Println (MK)
}
Example two:
A data structure to hold a key/value pair.
Type Pair struct {
Key string
Value int
}
A Slice of Pairs that implements sort. Interface to sort by Value.
Type Pairlist []pair
Func (P pairlist) Swap (i, J int) {P[i], p[j] = P[j], P[i]}
Func (P pairlist) len () int {return Len (p)}
Func (P pairlist) Less (i, J int) bool {return p[i]. Value < P[j]. Value}
A function to turn a maps into a pairlist, then sort and return it.
Func Sortmapbyvalue (M map[string]int) pairlist {
P: = Make (Pairlist, Len (m))
I: = 0
For k, V: = range m {
P[i] = pair{k, v}
}
Sort. Sort (P)
Return P
}