如何在Java中以相反的顺序迭代哈希映射
我正在尝试一个小时,但没有找到任何最佳方法来以相反的顺序实现哈希映射的迭代,这就是我拥有的哈希映射。
Map<Integer, List<String>> map = new HashMap<Integer, List<String>>();
for(Integer key : map.keySet()) {
List<String> value = map.get(key);
List<Map<String,?>> security = new LinkedList<Map<String,?>>();
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 }));
}
我也看过树图的例子,
Map<Integer, List<String>> sortedMap = new TreeMap<Integer, List<String>>(map);
但是树状图也按升序给出,我想要的是降序。