开发者

How can I sort arraylist hasmap

im wondering, how can I sort my arraylist: its look like this:

A开发者_开发技巧rrayList<HashMap<String, ?>> list = new ArrayList<HashMap<String, ?>>();
temp.put("Position", count);
list.add(temp);

I would sort by Position key.


please try it.

Comparator comparator = Collections.reverseOrder();
Collections.sort(list,comparator);

And also check it.

Sort a Map<Key, Value> by values (Java)


If what you want is to sort the map entries by their keys, you can use a SortedMap (e.g. TreeMap):

List<SortedMap<String, ?>> list = new ArrayList<SortedMap<String, ?>>();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜