OrderBy descending in Lambda expression?
As Brannon says, it's OrderByDescending
and ThenByDescending
:
var query = from person in people
orderby person.Name descending, person.Age descending
select person.Name;
is equivalent to:
var query = people.OrderByDescending(person => person.Name)
.ThenByDescending(person => person.Age)
.Select(person => person.Name);
Use System.Linq.Enumerable.OrderByDescending()
?
For example:
var items = someEnumerable.OrderByDescending();