I hope you saw the MSDN help page and code sample:
http://msdn.microsoft.com/en-us/library/bb534966.aspx[
^].
I suspect you don't understand (generics) delegates, lambda syntax (yes, for this simple application understanding syntax is quite enough) or maybe
IEnumerable
.
Lets see. You are required to supply a parameter, which is the method with the signature defined by the delegate type
Func<TSource, TKey>
. In your case, this is a function which accept one parameter which is of the type of your list element (double) and returns some key of the type for which the ordering operation is defined.
So, your code sample is correct, if you need to return a collection in natural order.
Without the lambda, you could write equivalent code:
static double GetOrderingCriterionKey(double value) { return value; }
IOrderedEnumerable<double> =
arrayresultMembership.OrderBy(new Func<double,>(GetOrderingCriterionKey));
If you need to change the order, use other
OrderBy
methods, those using
IComparer
, see
http://msdn.microsoft.com/en-us/library/he2s3bh7%28v=VS.100%29.aspx[
^].
See also the definition of the generic delegate type
Func
. In your case, it is instantiated as
delegate double DoubleFunction(double element);
About
IEnumerable
and
IOrderedEnumerable
, just read and understand this:
http://msdn.microsoft.com/en-us/library/system.collections.ienumerable.aspx[
^],
http://msdn.microsoft.com/en-us/library/bb534852.aspx[
^].
—SA