I have following var result = new List<Tuple<int, List<ProductionReportEntry>, int>>();
How I can sort it by the last integer , that the result will be from high to Low .
Thanks for help.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The easiest way is to use LINQ’s
OrderByDescending()extension method, it will sort your list in descending order from high to low and push it back into the list:That’s assuming you want to store it back int the original reference, of course you could assign it to another variable, etc…
Alternatively, you could do an in-place sort using
List.Sort()‘s overload that takes aComparisson<T>delegate:Alternatively, you could build a custom
IComparer<T>, of course for yourTuple<int, List<PropertyReportEntry>, int>but that gets pretty ugly looking…