var listOne = new string[] { "dog", "cat", "car", "apple"};
var listTwo = new string[] { "car", "apple"};
What I need is to order listOne by the order of items in listTwo (if present). So the new list would be in this order;
“car”, “apple”, “dog”, “cat”
I would like to do this in LINQ and have tried this;
var newList = from l1 in listOne
join l2 in listTwo on l1 equals l2 in temp
from nl temp.DefaultIfEmpty()
select nl;
But it returns null so evidently my Linq-Fu is weak. Any advise is appreciated.
You need all the items from listTwo that are in listOne followed by the remaining items from listOne?