c# - 用于对集合列表进行排序的 Lambda 表达式
问题描述
我的输入低于 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>
我在下面添加了代码,但它返回“位置”明智或“否”明智,但不是两者兼而有之。
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();
推荐阅读
- angular - 如何在分页中监听点击事件?查询选择器返回 null
- c# - Azure Functions 使用带有 Http 触发器的取消令牌
- c++ - boost::filesystem::recursive_directory_iterator 多线程安全
- python - 关于 Pandas 系列操作返回视图或副本的保证
- javascript - 如何在linux中打印.sh文件
- swift - 获取要 reloadRow 的值的特定 IndexPath
- c - 在 c 中使用 Pipe() 卡在 read() 上的程序
- javascript - JQueryBuilder 将规则保存在 sql 表中
- javascript - 具有嵌套 ng-repeat 的 AngularJS 过滤器数组
- r - 错误:在循环中使用 lm() 时变量的类型(列表)无效