标签:order div linq asc bsp pair entry pre code
Dictionary排序
对一个Dictionary<TKey, TValue>进行排序可以用LINQ:
Dictionary<string, string> MyDictionary = new Dictionary<string, string>();
1、键排序
MyDictionary = (from entry in MyDictionary orderby entry.Key ascending select entry).ToDictionary(pair => pair.Key, pair => pair.Value);
2、值排序
MyDictionary = (from entry in MyDictionary orderby entry.Value ascending select entry).ToDictionary(pair => pair.Key, pair => pair.Value);
标签:order div linq asc bsp pair entry pre code
原文地址:https://www.cnblogs.com/code1992/p/9759249.html