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)?

4

3 に答える 3

3

You can use OrderByDescending

UnUsedServices = UnUsedServices.OrderByDescending(si => si.utility).ToList(); 
于 2012-10-10T02:54:11.263 に答える
3

Try not to kick yourself: OrderByDescending :)

于 2012-10-10T02:54:12.370 に答える
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

于 2012-10-10T02:55:18.867 に答える