I have a class model somewhat like this:
public class MyModel
{
long MyModelID { get; set; }
}
I have a list of MyModel objects called TheListOfModels and a list of longs called TheListOfIDs: I want TheListOfModels to be sorted in the same order as TheListOfIDs.
What I have in mind is a loop that goes through the TheListOfIDs and at each iteration adds the corresponding TheListOfModels to a new list called SortedList and then reassigns that list to the original TheListOfModels.
Is this the best way to do it or is there a linq syntax for this specific operation?
Thanks.
This’ll do it: