开发者

Dictionary sort?

hey, i have a dictionnary like "key2","value2" "key3","value3" "key1","value1"

is it possible to sort it on va开发者_开发知识库lue ? If not, any other object can do same thing? (sort value on key/value pair)


Well, clearly you're talking about a Map.

It really depends on what Map you're using, You don't need to sort a TreeMap, coz it is already sorted.

For any other, You can get the keys using map.keySet() and use Collections.sort() to sort them. (Note, the map will remain the same, you'll get a Set containing all the key values)

Hope it helped.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜