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"} );排序依据字典健的长度来

来源:学生作业帮助网 编辑:作业帮 时间:2024/11/16 14:45:25
c# 字典 Dictionary排序问题现有字典Dictionary dic = new Dictionary();dic.Add(
x)KVVxv .%yE&=rfBIJ^fgԒҢ

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"} );排序依据字典健的长度来
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"} );

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"} );排序依据字典健的长度来
return dic.OrderByDescending(r => r.Key).ToDictionary(r => r.Key,r => r.Value);