19 如何按值对字典进行排序

来源:互联网 发布:怎么推广淘宝店铺 编辑:程序博客网 时间:2024/06/14 18:02
        static void SortDictionary()        {            Dictionary<string, string> diction = new Dictionary<string,string>();            diction.Add("3", "three");            diction.Add("1", "one");            diction.Add("5", "five");            diction.Add("2", "two");            List<KeyValuePair<string, string>> sortList = diction.ToList();            var sorted = from entry in diction orderby entry.Value ascending select entry;            Console.ReadLine();        }

0 0
原创粉丝点击