Redian新闻
>
[转载] How do I sort a map in Java?
avatar
[转载] How do I sort a map in Java?# Java - 爪哇娇娃
a*i
1
【 以下文字转载自 Programming 讨论区 】
【 原文由 ayanami 所发表 】
Supppose I have a HashMap wordmap with a String key, a integer value.
[Key=>value]
What is the easiest way to sort them based on value?
I looked at SortMap, but it only sorts based on key.
Thanks!
avatar
F*n
2
What is a Hashtable? Hashtable use hashCode to index data, so you can not
"sort" the value, the only way you can do is to create another sorted list of
values.

【在 a*****i 的大作中提到】
: 【 以下文字转载自 Programming 讨论区 】
: 【 原文由 ayanami 所发表 】
: Supppose I have a HashMap wordmap with a String key, a integer value.
: [Key=>value]
: What is the easiest way to sort them based on value?
: I looked at SortMap, but it only sorts based on key.
: Thanks!

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。