> 数学 >
c# 字典 Dictionary排序问题
现有字典
Dictionary dic = new Dictionary();
dic.Add("bca",new List(){"xkyz"} );
dic.Add("c",new List(){"xdz"} );
dic.Add("absdc",new List(){"xyz"} );
dic.Add("dxzcu",new List(){"fyz"} );
排序依据字典健的长度来排序,越长的越在前面,列表的值不变只改变顺序
Dictionary dic = new Dictionary();
dic.Add("dxzcu",new List(){"fyz"} );
dic.Add("absdc",new List(){"xyz"} );
dic.Add("bca",new List(){"xkyz"} );
dic.Add("c",new List(){"xdz"} );
人气:258 ℃ 时间:2020-01-25 20:14:45
解答
return dic.OrderByDescending(r => r.Key).ToDictionary(r => r.Key,r => r.Value);
推荐
猜你喜欢
© 2024 79432.Com All Rights Reserved.
电脑版|手机版