I have a class called Order
which has properties such as OrderId
, OrderDate
, Quantity
, and Total
. I have a l
Simplest way to order a list is to use OrderBy
List objListOrder =
source.OrderBy(order => order.OrderDate).ToList();
If you want to order by multiple columns like following SQL Query.
ORDER BY OrderDate, OrderId
To achieve this you can use ThenBy
like following.
List objListOrder =
source.OrderBy(order => order.OrderDate).ThenBy(order => order.OrderId).ToList();