0

I achieve this in this way

UnUsedServices = UnUsedServices.OrderBy(si => si.utility).ToList(); //order it ascendingly
UnUsedServices.Reverse();//reverse it

I just wonder is there a way to reverse it directly in descending order instead of splitting into two phases (sort ascending and reverse)?

Nalaka526
  • 11,278
  • 21
  • 82
  • 116
william007
  • 17,375
  • 25
  • 118
  • 194

3 Answers3

3

You can use OrderByDescending

UnUsedServices = UnUsedServices.OrderByDescending(si => si.utility).ToList(); 
Mark Oreta
  • 10,346
  • 1
  • 33
  • 36
3

Try not to kick yourself: OrderByDescending :)

aquinas
  • 23,318
  • 5
  • 58
  • 81
2

You can do this in one shot if you want it in descending order by using OrderByDescending

UnUsedServices.OrderByDescending(si => si.utility).ToList();

http://msdn.microsoft.com/en-us/library/system.linq.enumerable.orderbydescending.aspx

Disgone
  • 701
  • 4
  • 3