Javatpoint Logo
Javatpoint Logo

LINQ Sorting Operators (Order By, then By, Reverse)

Sorting Operators in LINQ are used to change the order or sequence of the data (either ascending or descending), which is based on one or more attributes.

Sorting Operators available in LINQ are:

  1. ORDER BY
  2. ORDER BY DESCENDING
  3. THEN BY
  4. THEN BY DESCENDING
  5. REVERSE
LINQ Sorting Operators

All these sorting operators are used to sort the data. But the REVERSE operator reverses the items in the collection. Rest operators are used to order the data just like we use Order by clause in SQL. These sorting operators are similar to SQL, but the only difference is that we are using the operators in LINQ.

From the table, it shows the detailed information related to sorting operators in SQL.

Operator Description Query Syntax
OrderBy This operator will sort the values in ascending order. ordeby
OrderByDescending This operator will sort the values in descending order. Orderby ......descending
ThenBy This operator is used to perform the secondary sorting in ascending order. Orderby...,....
ThenByDescending This operator is used to perform the sorting in descending order. Orderby....,....descending
Reverse This operator is used to reverse the order of elements in the collection. Not applicable






Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA