In LINQ, sorting operators are used to rearrange the given sequence in ascending or descending order based on one or more attributes. There are 5 different types of sorting operators are available in LINQ:
OrderByDescending operator is used to rearranging the elements of the given sequence in descending order. It does not support query syntax in C# and VB.Net. It only supports method syntax. If you want to rearrange or sort the elements of the given sequence or collection in descending order in query syntax, then use descending keyword as shown in below example.
And in method syntax, use OrderByDescending () method to sort the elements of the given sequence or collection. This method is present in both the Queryable and Enumerable class. And the method syntax is supported by both C# and VB.Net languages. As shown in the below examples. The OrderByDescending method sorts the elements of the collection according to a single property, you are not allowed to sort the collection using multiple properties.
Employee ID: 214 Employee ID: 213 Employee ID: 212 Employee ID: 211 Employee ID: 210 Employee ID: 209
Employee Name: Supriya Employee Name: Soniya Employee Name: Rohit Employee Name: Anju Employee Name: Anjita Employee Name: Anil
- LINQ | Sorting Operator | Reverse
- LINQ | Sorting Operator | ThenBy
- LINQ | Sorting Operator | ThenByDescending
- LINQ | Sorting Operator | OrderBy
- LINQ | Set Operator | Except
- LINQ | Set Operator | Union
- LINQ | Quantifier Operator | Any
- LINQ | Element Operator | First
- LINQ | Filtering Operator | where
- LINQ | Quantifier Operator | Contains
- LINQ | Partition Operator | Take
- LINQ | Set Operator | Distinct
- LINQ | Set Operator | Intersect
- LINQ | Quantifier Operator | All
- LINQ | Element Operator | Last
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.