Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7674269
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T16:42:04+00:00 2026-05-31T16:42:04+00:00

I am currently ordering a list of custom objects using the IQueryable OrderBy method

  • 0

I am currently ordering a list of custom objects using the IQueryable OrderBy method as follows:

mylist.AsQueryable().OrderBy("PropertyName");

Now I am looking to sort by more than one property. Is there any way to do that?

Thanks,
Yannis

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T16:42:05+00:00Added an answer on May 31, 2026 at 4:42 pm
    OrderBy(i => i.PropertyName).ThenBy(i => i.AnotherProperty)
    

    In OrderBy and ThenBy you have to provide keySelector function, which chooses key for sorting from object. So if you know property name only at runtime then you can make such function with Reflection like:

    var propertyInfo = i.GetType().GetProperty("PropertyName"); 
    var sortedList = myList.OrderBy(i => propertyInfo.GetValue(i, null)) 
    

    But it will be slower, then direct access to property. Also you can “compile” such function on the fly with Linq.Expressions and it will work faster than reflection but it is not very easy. Or you can use CollectionViewSource and their sorting ablilities in WPF.

    And don’t forget that OrderBy() returns sorted enumerable and it does not sort your existed List inplace. In your example you did not save sorted list to variable.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently, i'm sorting a list using LINQ to objects, then doing a ToList() on
I have the following method to apply a sort to a list of objects
Currently, I don't really have a good method of debugging JavaScript in Internet Explorer and
Currently if we get direction of ordering as an external dependency we have to
I am using Hibernate's @OrderColumn annotation to order a list in my database. It
I currently have an app (in Silverlight), using mv-vm, that has an interface to
I have a list that needs ordering say: R1-1 R1-11 R2-2 R1-2 this needs
I'm using Cancan, Devise, Rails 3 for my ordering application. Each user has many
I have been looking at nestedSet behaviour in symfony using doctrine, to display a
I would like to show a list of all post tags ordering them by

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.