Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LINQ OrderByDescending to OrderByAscending?

Tags:

c#

linq

How can I convert the following LINQ statement to OrderByAscending instead of OrderByDescending? There are for some reason no OrderByAscending:

            var unProfParameterSets = RawAARdDDArray1
               .Select((value, index) => new { value, index })
               .OrderByDescending(item => item.value)
               .Take(unProfParams)
               .Select(item => RawParamSet[item.index])
               .ToArray();

Thanks!

like image 929
ceds Avatar asked Feb 17 '12 06:02

ceds


1 Answers

The method to order results in accending order is OrderBy

 var unProfParameterSets = RawAARdDDArray1
           .Select((value, index) => new { value, index })
           .OrderBy(item => item.value)
           .Take(unProfParams)
           .Select(item => RawParamSet[item.index])
           .ToArray();
like image 149
Eranga Avatar answered Oct 24 '22 10:10

Eranga