I have 2 lists, one is the original list and the other is a sorted list. I want to sort the first list by the second list, but my method will not return anything, so it must sort the list in place.
I did this method:
public void SortByList(IEnumerable<JObject> source, IEnumerable<JObject> products)
{
var ids = source.Select(m => m["_id"].ToString()).ToList();
products.OrderBy(m => ids.IndexOf(m["_id"].ToString()));
}
But as you know, OrderBy
creates a new list. How can I Sort
using the ids?