Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


I am trying to order a set of numbe

I am trying to order a set of numbe

I am trying to order a set of numbe

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?



RE: I am trying to order a set of numbe

Try doing your code up to the Distinct()
then try using var something = columns.OrderBy(x... and see if that works

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close