I have the list like this
public class Col
{
public long Id { get; set; }
public Dictionary<string, dynamic> Dt { get; set; }
}
var list = IEnumerable<Col>;
I need to sort the List using dictionary
I tried a lot of methods, but nothing helps, there is an error:
System.ArgumentException: At least one object must implement IComparable.
The last thing I stopped at was:
list.OrderBy(x => x.Dt.Where(r => r.Key == "Smile").Select(r => r.Value));
Sorting should be done by the Dictionary value
Update1:
I want to sort the block that I have selected, but sort not by Id, but by the data in the dictionary
CodePudding user response:
Try this:
list.OrderBy(c => c.Dt[<YourKeyValue>]);