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 4347776
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T12:21:09+00:00 2026-05-21T12:21:09+00:00

So-called natural sort is meant to address the following problem: when users expect file1.txt

  • 0

So-called natural sort is meant to address the following problem: when users expect

file1.txt
file2.txt
file3.txt
file10.txt
file11.txt

“usual” sort instead produces:

file1.txt
file10.txt
file11.txt
file2.txt
file3.txt

which is inconvenient and isn’t “natural”.

Now we recently faced a situation when users complained about this very same problem and we considered employing natural sort. However the following problem arised. Consider the following set of strings:

file1file100.txt
file2file99.txt
...
file99file2.txt
file100file1.txt

in which there’s more than one identifiable number sequence and those sequences are in opposite to each other. How should natural sort deal with such sets (I mean what should the result be, not how to implement that)?

  • 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-21T12:21:10+00:00Added an answer on May 21, 2026 at 12:21 pm

    The one that comes first wins, surely.

    Usual sort lexicographically sorts filenames as sequences of characters (well, perhaps with special treatment of file extensions, although that might be implemented just by ordering . first among characters) : 'f', 'i', 'l', 'e', '1', 'f', 'i', 'l', 'e', '1', '0', '0'.

    Natural sort lexicographically sorts filenames as sequences of tokens, where each token is either a character or a number: 'f', 'i', 'l', 'e', 1, 'f', 'i', 'l', 'e', 100. Comparison between characters is normal character order, comparison between numbers is normal integer order, and comparison between a character and a number places numbers before any character (except .). Finally you need to break the tie between file1 and file01, so the “numbers” aren’t quite just numbers, they do need to “know” their original representation in case it gets that far.

    I’d actually sort of advise against asking the users. If they have a really strong opinion how they want their files sorted then OK, fair enough. Otherwise they might not actually know exactly what they “should” expect, so it makes more sense for an analyst/programmer to figure out what’s “normal” than for a user to do so. Of course you can “ask” them indirectly via usability testing, if it’s a big enough deal to be worth it. I find that if you ask users the wrong questions, they feel pressured to guess answers, and there’s no point coding something arbitrary just because it’s what the user representative thought of on the spot.

    Whatever users think the rules should be, chances are what they’ll actually get on with best is whatever their OS does by default when listing files in its file manager, file dialogs, and that sort of thing. So I’d offer them that (or perhaps the closest to that I can code without wasting a lot of their money on minor edge cases), and if they’re still not happy find out why.

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

Sidebar

Related Questions

Let's say I define the sequence of all natural numbers in the following way:
Consider the following problem: given a list of length three of tuples (String,Int), is
called a function like :- $setmessage = setlatestmessage($sessionid, $sendersuserid, $message1); the function is in
content called by AJAX content requires different shapes and sizes of cluetips (I use
I called my main activity Main, and Eclipse created Main.java and res/layout/main.xml for the
I called $('#tabs').tabs('load',0) to load the first tab, and the server return a response
I have a PartialView called TopPanel. This Panel is responsible for displaying error messages
I have a model called Event and another called Product. An event has many
on the page: onCreate called for two tabs each time one tab is selected
I have a class called: ComplexNumber and I have a string that I need

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.