Reputation: 2863
I am developing in Android , and I want to sort the the HashMap<String , Byte>
. It print the all value like the following code and log:
for (Object key : groups.keySet()) {
Log.d("addGroup", "groups.get(key) = " + groups.get(key) + " , key = " + key);
}
And the log show like the following:
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
How to sort the HashMap by value?
Thanks in advance.
Upvotes: 0
Views: 437
Reputation: 334
Have a look here Ordering HashMap
Upvotes: 1