This is what you mean? (Using Linq)
var merged = list1.Union(list2).OrderByDescending(d => d.Date);
Note that this is only possible, when the two lists are the same type.
Other note, that this returns an IEnumerable, not a new List, so every time you enumerate it, the merge will be calculated. You have to call ToList() at the end if you want to create a new List to prevent this, but this can be very suboptimal in performance if you have large lists.
Example program:
using System;
using System.Collections.Generic;
using System.Linq;
namespace Lists
{
class Program
{
static void Main(string[] args)
{
var list1 = new List<DateItem>
{
new DateItem{Date = DateTime.UtcNow.AddDays(-2), Name = "The day before yesterday" },
new DateItem{Date = DateTime.UtcNow.AddDays(1), Name = "Tomorrow" }
};
var list2 = new List<DateItem>
{
new DateItem{Date = DateTime.UtcNow.AddDays(2), Name = "The day after tomorrow" },
new DateItem{Date = DateTime.UtcNow.AddDays(-1), Name = "Yesterday" },
new DateItem{Date = DateTime.UtcNow, Name = "Today" }
};
var merged = list1.Union(list2).OrderByDescending(d => d.Date);
foreach (var day in merged)
{
Console.WriteLine(day.Name);
}
}
}
class DateItem
{
public DateTime Date { get; set; }
public string Name { get; set; }
}
}