Sort a List in C# by Date

We can use the Sort Method of LINQ, and use the CompareTo delegate.

If your List contains collection of objects, where each object has a date identifier, you could use the following code to sort:

myObject.Sort((a, b) = a.dateFieldName.CompareTo(b.dateFieldName));
Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Overview

Recent Articles: