I have a class called
Order which has properties such as
Total. I have a list of this
List<Order> objListOrder = new List<Order>(); GetOrderList(objListOrder); // fill list of orders
I want to sort the list based on one property of the
Order object; for example, either by the order date or the order id.
How can I do this in C#?
The easiest way I can think of is to use Linq:
List<Order> SortedList = objListOrder.OrderBy(o=>o.OrderDate).ToList();