Retrieve fixed number of entries around an entry in a map sorted by values
The POJO viz. Entry.java represents an entry in the leaderboard. Position is the position in the leaderboard, 1 being the user with the highest score public class Entry { private String uid; private int score; private int position; @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + score; result = prime * result + ((uid == null) ? 0 : uid.hashCode()); return result; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; if (!(obj instanceof Entry)