我的输入在xml文件下面
<Employees>
<Department Position="9">
<Employee No="7" Status="True" />
<Employee No="6" Status="True" />
<Employee No="8" Status="True" />
</Department>
<Department Position="4">
<Employee No="7" Status="True" />
<Employee No="8" Status="True" />
<Employee No="6" Status="True" />
</Department>
</Employees>
Out put should be sorted by department position and employee "No"
<Employees>
<Department Position="4">
<Employee No="6" Status="True" />
<Employee No="7" Status="True" />
<Employee No="8" Status="True" />
</Department>
<Department Position="9">
<Employee No="6" Status="True" />
<Employee No="7" Status="True" />
<Employee No="8" Status="True" />
</Department>
我添加了下面的代码,但它要么返回“position”明智的,要么返回“No”明智的,但不会同时返回两者。
var sortSignalList = new Dictionary<int, List<string>>();
sortSignalList.OrderBy(x => x.Position).OrderBy(x=>x.No).ToList();
最佳答案
sortSignalList.OrderBy(x => x.Position).ThenBy(x=>x.No).ToList();
关于c# - 用于对集合列表进行排序的 Lambda 表达式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53644785/