I have 2 lists Variant and MaterialOrder and in list variant, I have more than 500+ materials and in list MaterialOrder, I have 100 materials. Here I need to sort the materials in variant based on Material order.
public class Variant { public virtual string ItemNo { get; set; } } public class MaterialOrder { public string ItemNo { get; set; } public int Orderno { get; set; } } var MaterialOrderdetails = (await materialTask)?.ToList() ?? new List<MaterialOrder>(); // List all materials with Orderno // variants holds 500+ materials // getting error At least one object must implement IComparable. variants = variants.OrderBy(a => MaterialOrderdetails.Where(b => b.ItemNo == a.ItemNo));
variant. But what order do you want? Do you want them in the same order as the ItemNo in sequence of MaterialOrders? What if you have an ItemNo in variant that is not in MaterialOrders? Consider to edit the question and write a proper unambiguous specification