Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I am trying to order a set of numbe

Status
Not open for further replies.

tfstom

Programmer
Sep 28, 2002
190
0
0
US
I am trying to order a set of numbers in Linq.

var columns = source.Select(columnSelector).Distinct().OrderBy(x => x?

x => x in intellisense only has normal object selections (Equals, GetHashCode, GetType and ToString).

columnsSelector is passed as: "Func<T, TColumn>". This is just a list of numbers or strings that will become the columns names in a pivot.

It works fine, but not sorted. So I end up with: 1, 3, 2, 4. I want to order this so wanted to add the "OrderBy" to the code, but I can't seem to get a value for the Lambda expression that OrderBy expects.

How would I solve this?

Thanks,

Tom
 
Try doing your code up to the Distinct()
then try using var something = columns.OrderBy(x... and see if that works
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top