I have a list of lists.
List<List<T>> li = {
   {a1,a2,a3 ... aN},
   {b1,b2,b3 ... bN},
   ...
};
double foo(List<T> list)
{
    // do something 
    // e.g {1,2,3} 
    // it = 1 + 2 + 3
    return it;
}
Now I want to sort li in such a way that higher the foo(x) for a x higher it should appear in a sorted list.
What is the best way in C#/Python/any other lang to this?
With a little bit of LINQ:
var q = from el in li
        orderby foo(el)
        select el;
li = q.ToList();
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With