Here's a simple, effective approach:
var orderedRooms = rooms
.OrderBy(room => !room.People.Any(person => person.IsLead))
.GroupBy(room => room.RoomType)
.SelectMany(group => group);
This request meets the following requirements:
- The first room on the ordered list is the one that contains the lead.
- All numbers of the same type follow each other.
However, it does not sort room types in alphabetical order.
source
share