按价值排序字典 [英] Sorting a Dictionary by Value

查看:190
本文介绍了按价值排序字典的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个字典:

{ "honda" : 4, "toyota": 7, "ford" : 3, "chevy": 10 }

我想排序第二列(价值)下降。

I want to sort it by the second column aka (the value) descending.

期望的输出:


chevy 10

"chevy", 10

丰田,7

本田,4

ford,3


推荐答案

感谢caryden从:
如何按价值排序字典?

Thanks to caryden from: How do you sort a dictionary by value?

Dim sortedDict = (From entry In dict Order By entry.Value Descending Select entry)

上述问题是由于循环不正确。

The issues reported above were due to improper looping.

这篇关于按价值排序字典的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆