Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to sort a Map with Enums

 
vuthlarhi donald
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20605
60
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use a TreeMap and provide a Comparator<Titles> or perhaps even a Comparator<Enum><?>> to the constructor.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic