我正在开发Android,我想对HashMap<String , Byte>
进行排序。它打印所有值,如下面的代码和日志:
for (Object key : groups.keySet()) {
Log.d("addGroup", "groups.get(key) = " + groups.get(key) + " , key = " + key);
}
日志显示如下:
groups.get(key) = -6 , key = iii
groups.get(key) = -5 , key = qqq
groups.get(key) = -3 , key = bbb
groups.get(key) = -7 , key = xxd
groups.get(key) = -2 , key = kmn
groups.get(key) = -4 , key = hhh
groups.get(key) = -12 , key = yhn
groups.get(key) = -9 , key = 987
groups.get(key) = -13 , key = zxc
groups.get(key) = -10 , key = hxt
groups.get(key) = -11 , key = tfx
如何按值对HashMap进行排序?
提前致谢。