I have already looked at sorting a HashMap by value here but I'm not quite sure how to extract top 'n' entries of this sorted HashMap. Or is there a better way of accomplishing this?
To provide some overview, I'm working on a P2P project and I maintain a mapping between peerID and the corresponding rate at which files can be downloaded from each of those peers. Then I need to select top 'n' peers with highest download rates.