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

  • SEARCH
  • Home
  • 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 7782731
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T19:37:57+00:00 2026-06-01T19:37:57+00:00

Consider this code: var files = Directory.GetFiles(filePath); var dataFiles = from file in files

  • 0

Consider this code:

 var files = Directory.GetFiles(filePath);
 var dataFiles = from file in files
                 where System.IO.Path.GetExtension(file) == extension 
                 orderby file.Length
                 select file;

I’ve been looking for a string comparator that will do “natural sort”. Sadly, there is no build-in functionality for this common task. I found this post and it looks good.

Can I use NaturalStringComparer with LINQ query syntax? I am aware of the solution with lambdas.

  • 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-06-01T19:37:59+00:00Added an answer on June 1, 2026 at 7:37 pm

    Unfortunately this is not possible since the overload of OrderBy with a custom comparer is not supported in query syntax – only method syntax makes it accessible:

    var comparer = new NaturalStringComparer();
    var dataFiles = files.Where(f => System.IO.Path.GetExtension(f) == extension)
                         .OrderBy(f => f, comparer);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider this code: var query = from groupRole in CurrentItem.MEMGroupRoles select groupRole.MEMRole; this.AvailableRoles =
Consider this code: var img = new Image(); img.onload = function() { console.log(this.width); };
Consider this code... using System.Threading; //... Timer someWork = new Timer( delegate(object state) {
Consider this code: public <T> List<T> meth(List<?> type) { System.out.println(type); // 1 return new
Consider this code: int x = 17; int y = 013; System.out.println(x+y = +
Consider this piece of code: using System; using System.Collections.Generic; using System.Linq; using System.Text; using
Consider this code: var query = db.Table .Where(t => SomeCondition(t)) .AsEnumerable(); int recordCount =
Consider this code... $(function() { for (var i = 0; i < 10; i++)
Consider this code: int size = 100 * 1000 * 1000; var emu =
Consider this code attempting to create an Active Directory account. It's generating an exception

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.