Let's say I have a list of objects:
var items = new {
new { Order = 0 },
new { Order = 1 },
new { Order = -1 },
new { Order = 3 },
new { Order = 2 },
new { Order = -1 }
};
I need to order it so that items with "Order > -1" be on top of the list ordered by Order ascending, and remaining items with "Order == -1" were following them.
Is there a more elegant way of doing this than using Conact() + Where() clauses:
var orderedItems = items.Where(x => x.Order > -1).OrderBy(x => x.Order)
.Conact(items.Where(x => x.Order == -1);
So that after sorting this list would look like:
var items = new {
new { Order = 0 },
new { Order = 1 },
new { Order = 2 },
new { Order = 3 },
new { Order = -1 },
new { Order = -1 }
};
Also "items" list in actual scenario is already a complex IQueryable object. That's why I am trying to find the most optimal way of doing such selective ordering.