你如何按价值排序字典?

▼魔方 西西 提交于 2020-07-26 06:37:14

问题:

I often have to sort a dictionary, consisting of keys & values, by value. 我经常需要按值排序字典,包括键和值。 For example, I have a hash of words and respective frequencies, that I want to order by frequency. 例如,我有一个单词和各自频率的哈希,我想按频率排序。

There is a SortedList which is good for a single value (say frequency), that I want to map it back to the word. 有一个SortedList适用于单个值(比如频率),我想将它映射回单词。

SortedDictionary orders by key, not value. SortedDictionary按键排序 ,而不是值。 Some resort to a custom class , but is there a cleaner way? 有些人诉诸于自定义课程 ,但是有更清洁的方法吗?


解决方案:

参考一: https://stackoom.com/question/4f/你如何按价值排序字典
参考二: https://oldbug.net/q/4f/How-do-you-sort-a-dictionary-by-value
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!