I have one array list
ArrayList itemListWithRank = ItemListDAO.getItemList();
and in arraylist itemListWithRank there are lots of type of objects values those all are different. And one value from them is item rank that also set with that array list.
Now i want to sort this array list based on accending order of rank. Rank value is already set in this array list.
How can i sort arraylist which one have lots of type of values….?
Thanks all….
Make them all object of a type. either design a common Base class or an
Interfaceand then
use
Comparatorto sort them outFor example.
assumed that all the objects in arraylist are SortableFields now
Now
Or use reflection hack , not preferable
In your UtilClass