Dofactory.com
Dofactory.com

How to sort a C# List<T> by a property in the object.

Use a Linq OrderBy() extension method, like so:


var orders = new List<Order>();

var sortedList = orders.OrderBy(o => o.OrderDate).ToList();


Jack Poorte
Jack Poorte
Last updated on Sep 30, 2023



Stay Inspired!
Join other developers and designers who have already signed up for our mailing list.
Terms     Privacy     Cookies       Do Not Sell       Licensing      
Made with    in Austin, Texas.  - vsn 44.0.0
© Data & Object Factory, LLC.