Treeset to order elements in descending order
Posted
by Gaurav Saini
on Stack Overflow
See other posts from Stack Overflow
or by Gaurav Saini
Published on 2009-07-07T08:10:59Z
Indexed on
2010/05/18
22:00 UTC
Read the original article
Hit count: 443
Here is the piece of code that I have used for Java 5.0
TreeSet<Integer> treeSetObj = new TreeSet<Integer>( Collections.reverseOrder() ) ;
Collections.reverseOrder() is used to obtain a comparator in order to reverse the way the elements are stored and iterated.
Is there a more optimized way of doing it?
© Stack Overflow or respective owner