There is a list of objects sorted in the order I need. Then I receive a new list in which there are id objects from the first list. The second list is sorted by its. How can I sort it by id_from_firstlist in the order in which they appear in this first list? The first list is sorted by the field which is not in the second list. Now I am doing this in a not quite elegant way. I think there may be some kind of human method without an additional list?
var firstList = new List<Data1>(); var secondList = new List<Data2>(); var sorted = new List<Data2>(); firstList.Each(zz => { sorted.Add(secondList.First(z => z.id_from_firstlist == zz.Id));});