I have been using the Counter() data structure in Python as a key-value store that allows me to have the objects sorted according to their value using the most_common method. More info here.
Is there any similar data structure for the Java language? For example, I have seen many related answers that focus on sorting HashMaps or TreeMaps by the data structure is not initially defined for that purpose. In my case I usually need to to keep counters of objects and then to select the most common or the ones with the highest score (Top-N queries). However, it is difficult for me since I need to insert to a HashMap and then sort or to use multiple data structures.