To find the kth largest key in a map in Go, one possible approach is to create a slice of keys from the map, sort it in descending order, and return the kth element. Another approach is to use a max heap of keys, remove the largest elements k times, and return the kth element. Here is an example implementation of both methods:
main.go1160 chars54 lines
Note that both methods assume that the keys in the map are of type int, but you can modify the code to work with other types or use generics in Go 2.0 when it becomes available.
gistlibby LogSnag