I’m trying to sort a list.
This line throws the exception: ;
List<DistanceInfo> ListedDuration =
Distances.OrderBy(o => o.Rows[0].Elements.OrderBy(e => e.Distance))
.ToList();
But, this works:
List<DistanceInfo> ListedDuration =
Distances.OrderBy(o => o.Rows[0].Elements[0].Distance)
.ToList();
How can I fix this ?
Let’s look at:
The thing we are ordering by is:
which is to say; for each item
o, order it by the sequence ordered by distanceo.Rows[0].Elements.OrderBy(e => e.Distance). That doesn’t make much sense. How do you compare two sequences, such as{1,3,4}to{1,8}?You might, however, take the first distance, or the min / max distance: