I have two List which I am accessing by index (e.g. Name[10]
, Date[10]
). They\'re closely tied, so Name[10]
is related to Date[1
You could create a custom type to hold a value, or if you only need to use it in the scope of a single method you could use an anonymous type as follows.
var namesAndDates = MyNames
.Select((name, i) => new {name, date = MyDates[i]});
From here the two values are no longer loosely tied. Now you can sort them.
var sortedNamesAndDates = namesAndDates.OrderBy(a => a.date);
Or whatever else you'll need to do with them.