I know in normal linq grammar, "orderby xxx descending" is very easy, but how do I do this in Lambda expression?
+2
A:
Use System.Linq.Enumerable.OrderByDescending()
?
For example:
var items = someEnumerable.OrderByDescending();
Brannon
2009-10-28 06:31:45
+6
A:
As Brannon says, it's OrderByDescending
and ThenByDescending
:
var query = from person in people
order by 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);
Jon Skeet
2009-10-28 06:34:24