Sort a List so a specific value ends up on top
问题 I have a class Offer which contains a filed Category. I want all Offers of a specific category to appear on top, followed by all else. I tried this, but to no avail, what would you recommend? Offers = Offers.OrderBy(x => x.Category == "Corporate").ToList(); 回答1: When you order by a boolean value false (0) comes before true (1). To get the elements that match the predicate first you should reverse the sort order by using OrderByDescending : Offers = Offers.OrderByDescending(x => x.Category ==