There is an ascending keyword that can be used in the same context as the descending keyword (following an orderby clause). Ascending sorts are normally the default.
using System;
using System.Linq;
class Employee
{
public int Salary { get; set; }
public int Id { get; set; }
}
class Program
{
static void Main()
{
Employee[] array = new Employee[]
{
new Employee(){Salary = 40000, Id = 4},
new Employee(){Salary = 40000, Id = 0},
new Employee(){Salary = 60000, Id = 7},
new Employee(){Salary = 60000, Id = 9}
};
// Highest salaries first.
// ... Lowest IDs first.
var result = from em in array
orderby em.Salary descending, em.Id ascending
select em;
foreach (var em in result)
Console.WriteLine(
"{0}, {1}", em.Salary, em.Id);
}
}
60000, 7
60000, 9
40000, 0
40000, 4