File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Help required: sorting HashMap values Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Help required: sorting HashMap values" Watch "Help required: sorting HashMap values" New topic

Help required: sorting HashMap values

Nidhi Singhal
Ranch Hand

Joined: Sep 19, 2004
Posts: 89


I want to know how to sort values (not keys) in a HashMap

Sonny Gill
Ranch Hand

Joined: Feb 02, 2002
Posts: 1211

What problems did you run into while trying to do it?
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
You can create a list of the Map.Entry objects in the Map and sort them with a custom Comparator. See the link to the API docs in my sig for information on the Map.Entry class and the Comparator interface.


Java API Documentation
The Java Tutorial
I agree. Here's the link:
subject: Help required: sorting HashMap values
It's not a secret anymore!