C# 14 · Collections and LINQ
Sort by one or more keys
Sort by one key, then break ties with another.
var sorted = users.OrderBy(u => u.LastName).ThenByDescending(u => u.Age);
C# 14 · Collections and LINQ
Sort by one key, then break ties with another.
var sorted = users.OrderBy(u => u.LastName).ThenByDescending(u => u.Age);
Was this page helpful?