Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

How do I retrieve the values of a Hashtable/HashMap in sorted order?

hashmap hashtable sorted values
0
Posted

How do I retrieve the values of a Hashtable/HashMap in sorted order?

0

Location: http://www.jguru.com/faq/view.jsp?EID=503126 Created: Sep 25, 2001 Modified: 2001-11-29 22:45:37.037 Author: John Zukowski (http://www.jguru.com/guru/viewbio.jsp?EID=7) Question originally posed by Ajay Tejwani (http://www.jguru.com/guru/viewbio.jsp?EID=418246 Basically, you can’t directly do this. What you can do is get the Collection of values() back from the map and create a sorted collection, or maintain two maps, one in each direction, and keep the second map sorted by being a TreeMap. Which you use depends on the frequency you must sort the elements.

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123