C#LINQThenBy

Performs a subsequent ordering of the elements in ascending order.

Syntax

source.ThenBy(keySelector)

Example

Enter values below to update the example in real time.

var
people
new
Name
sorted
OrderBy
ThenBy
var people = new[] {
    new { Name = "Bob", Age = 30 },
    new { Name = "Alice", Age = 25 },
    new { Name = "Alice", Age = 20 }
};
var sorted = people.OrderBy(p => p.Name).ThenBy(p => p.Age);