C# Grouping a sorted List by following value

Solution 1:

You want kind of consecutive grouping? You can use the following loop:

List<Order> orders = // your list

List<List<Order>> orderGroups = new List<List<Order>>();
if(orders.Count > 0) orderGroups.Add(new List<Order> { orders[0] });

for (int i = 1; i < orders.Count; i++)
{
    Order currentOrder = orders[i];
    if (orders[i - 1].DeliveryPerson != currentOrder.DeliveryPerson)
        orderGroups.Add(new List<Order> { currentOrder });
    else
        orderGroups.Last().Add(currentOrder);
}