I am trying this for some hour but not finding any best approach to achieve iteration of hashmap in reverse order, this is the hashmap I have.
Map
You can use TreeMap#descendingKeySet method.
TreeMap#descendingKeySet
Map> map = new TreeMap>(); for(Integer key : map.descendingKeySet()) { List value = map.get(key); List> security = new LinkedList>(); for(int ixy = 0; ixy < value.size()-1; ixy++){ security.add(createItem(value.get(ixy), value.get(ixy+1))); } adapter.addSection(Integer.toString(key), new SimpleAdapter(getApplicationContext(), security, R.layout.list_complex, new String[] { ITEM_TITLE, ITEM_CAPTION }, new int[] { R.id.list_complex_title, R.id.list_complex_caption })); }
Reference:
https://docs.oracle.com/javase/8/docs/api/java/util/TreeMap.html#descendingKeySet--