LINQ ThenBy Operator

LINQ ThenBy Operator is used when we want to sort the elements in a collection by using multiple properties in ascending order.

This operator must use after OrderBy or OrderByDescending operator. First OrderBy operator sort the collection based on a single property and then we can use ThenBy operator to sort the collection by second property. We can use multiple ThenBy operator in a collection.

In the above example, we sort the collection based on Rank and Age properties. First collection is sorted based on Rank property and then by Age property. If we want to further sort the collection we can add another property by appending comma and property name.