How to sort the next list
The easiest way is to use LINQ extension method OrderByDescending()
, it will sort your list in descending order from high to low and insert it back into the list:
result = result.OrderByDescending(t => t.Item3).ToList();
Suppose you want to save it back to the original link, of course you can assign it to another variable, etc.
Alternatively, you can do an in-place sort using an overload List.Sort()
that the delegate takes Comparisson<T>
:
// does descending since we put r on the lhs and l on the rhs...
result.Sort((l, r) => r.Item3.CompareTo(l.Item3));
Alternatively, you can create a custom one IComparer<T>
, of course, for your own Tuple<int, List<PropertyReportEntry>, int>
, but that looks pretty ugly ...
source to share