File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes How to sort a Map with Enums Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How to sort a Map with Enums" Watch "How to sort a Map with Enums" New topic
Author

How to sort a Map with Enums

vuthlarhi donald
Ranch Hand

Joined: Jul 31, 2006
Posts: 76
Iwant to sort the map, so that when I print the result's ...everything must be sorted with aphabetical order, with the ordinal values as well. so I can't use a TreeMap, because that will only sort the values of the enums/ordinal values...I am running out of ideas..help.



Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19649
    
  18

Use a TreeMap and provide a Comparator<Titles> or perhaps even a Comparator<Enum><?>> to the constructor.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
Don't get me started about those stupid light bulbs.
 
subject: How to sort a Map with Enums
 
Similar Threads
Sorting Maps
Enums in a map
enum in Tiger
XML Schema design help
html:options - having difficulty preselecting item