using System.Collections.Generic;
public static void Main()
Console.WriteLine("Hello World");
List<Tuple<string, DateTime>> variantsToBeUpdated = new List<Tuple<string, DateTime>>();
variantsToBeUpdated.Add(new Tuple<string, DateTime>("12345", new DateTime(2019, 2, 3)));
variantsToBeUpdated.Add(new Tuple<string, DateTime>("12345", new DateTime(2018, 2, 3)));
variantsToBeUpdated.Add(new Tuple<string, DateTime>("45678", new DateTime(2019, 2, 3)));
variantsToBeUpdated.Add(new Tuple<string, DateTime>("45678", new DateTime(2015, 2, 3)));
variantsToBeUpdated.Add(new Tuple<string, DateTime>("6666", new DateTime(2015, 2, 3)));
variantsToBeUpdated.Add(new Tuple<string, DateTime>("6666", new DateTime(2018, 2, 3)));
var filteredVariantsToBeUpdated = variantsToBeUpdated.GroupBy(x => x.Item1).Select(x => new {x.Key, Values = x.Select(item => new {item.Item2})});
var filteredVariantsToBeUpdated2 = variantsToBeUpdated.GroupBy(x => x.Item1).Select(g => g.OrderByDescending(x => x.Item2).FirstOrDefault());
foreach (var f in filteredVariantsToBeUpdated2)