Reputation: 11
My input is below xml file
<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>
I have added below code but it returns either "position" wise or "No" wise but not both.
var sortSignalList = new Dictionary<int, List<string>>();
sortSignalList.OrderBy(x => x.Position).OrderBy(x=>x.No).ToList();
Upvotes: 1
Views: 54
Reputation: 26
List can also be Sorted ThenByDescending
var thenByDescResult =sortSignalList.OrderBy(s => s.Position).ThenByDescending(s => s.No);
Upvotes: 0
Reputation: 6864
Try....
sortSignalList.OrderBy(x => x.Position).ThenBy(x=>x.No).ToList()
Upvotes: 0