It's not a secret anymore!
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’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: Help required: sorting HashMap values
jQuery in Action, 3rd edition