list - Sorting Custom Objects with Parameter in .NET? -


Assume that I have a custom object fu

Does any way I sort through the list I can do these objects, like

  list  

Also, this list may be able to sort with a qualified parameter. I feel that I need to define two different types.

, but I'm not sure.

Edit: Using the built-in list depends on how the object is sorted depends on whether the parameter has been passed or not. I can use a global variable and use it for sorting, but it creates a bad back code:

It's quite easy in C # to create lambda functions for both, and you can specify the right parameter in the lambda function. I know that VB supports extensions methods, but I'm not sure about Lambda functions.

  // Amount of Sorting based on Natural Order: List & lt; Int32 & gt; Ints = GetInts (); Ints.Sort ((lhs, rhs) = & gt; lhs.Compare (rhs)); // Sorting Foo Objects based on some calculation: list & lt; Foo & gt; Fuses = gatefuos (); Foos.Sort ((lhs, rhs) => lhs.Compute (pValue) .comre (rhs.Compute (pValue));  

Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -