hey,
i have a dictionnary like
“key2″,”value2”
“key3″,”value3”
“key1″,”value1”
is it possible to sort it on value ?
If not, any other object can do same thing? (sort value on key/value pair)
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Well, clearly you’re talking about a
Map.It really depends on what
Mapyou’re using, You don’t need to sort aTreeMap, coz it is already sorted.For any other, You can get the keys using
map.keySet()and useCollections.sort()to sort them. (Note, the map will remain the same, you’ll get aSetcontaining all the key values)Hope it helped.