I want to sort an object and sort the object based on another collection item in LINQ. Say I have an object as follows:
[0] = { ID: 1090 , Name : Test1 }
[1] = { ID: 120 , Name : Test2 }
[2] = { ID: 1240 , Name : Test3 }
To be sorted based on this item collection
ColItem : [0] = 1240
[1] = 120
[2] = 1090
So expected output should be:
[0] = { ID: 1240 , Name : Test3 }
[1] = { ID: 120 , Name : Test2 }
[2] = { ID: 1090 , Name : Test1 }
I know I can do this by doing a loop in the ColItem, then mapped the value in the ID field from the object. But I want to do it in LINQ with a single line of code. Is that possible? Then, how to do that in LINQ with a single query?