Natural Order Sorting
Moderators: Hacker, petermad, Stefan2, white
so, if you have the following files: 1.gif, 2.gif, 20.gif, 3.gif, you would prefer this oder, instead of 1.gif, 2.gif, 3.gif, 20.gif. I mean, I don't know how you count... but here 20 if after 3!
It's not ASCII order, but NATURAL oder... how the most people count!
It's not ASCII order, but NATURAL oder... how the most people count!
Free fast image hosting: http://picserver.org/
Natural Order Numerical Sorting seems a good idea to me. I did not read the algorithm in detail, but it's very easy to imagine that it can be reversed. All you have to do is to decide yourself whether you want to sort the non-numeric parts from start (0) to end (length-1) or from end to start. I guess that also the syntax for numeric substrings could be made configurable (including the direction).VadiMGP wrote:It's very hard(at least for me:?) to imagine the good algorithm for the "natural" sorting. The numbers in filename is just charachters. How should be sorted files 1pic2.jpg, 2pic5.jpg, 5pic3.jpg? BTW i live in Israel and in hebrew filenames sometimes used right-to-left reading order. Any suggestion?I think is much more easy to use standard sorting and zero-leading padding.
well, the algorithm is a bit more complicated, because 1.10 also goes after 1.9 in it... but it's not very difficult. It's also imlemented by default in for example PHP, and i'm sure there is a Delphi class for it. TC is written in Delphi, right?
Free fast image hosting: http://picserver.org/
I think you want to tell me that "1.10" is not considered as one single numeric substring, but as "1" (numeric) + "." (non-numeric) + "10" (numeric). I admit that I was not aware of this, but nevertheless I cannot see a contradiction to my previous post. I did not define what the algorithm considers as a numeric substring.ddofborg wrote:well, the algorithm is a bit more complicated, because 1.10 also goes after 1.9 in it...
Yes.ddofborg wrote:TC is written in Delphi, right?
You're all asking for a lot of programming work to go into something which is so trivial and minor that it's simply not worth the effort. You should all be padding your numbered files with zeros anyway if you want them to appear in alphabetical order. TC already includes a very powerful multi-renaming tool which makes this very easy to do.
I sincerely hope Christian ignores this and spends his valuable time working on more important useful feature requests.
I sincerely hope Christian ignores this and spends his valuable time working on more important useful feature requests.
- fabiochelly
- Power Member
- Posts: 603
- Joined: 2003-02-05, 12:03 UTC
- Location: Rambouillet, France
Personally, I solved this problem by using left zeros for all lists I have to create.
If the files are sent to me like this, it takes less than an minute to change them with left padding zeros with the multirename tool.
I prefer to keep the actual way of sorting files because I think it could have erratic behaviours in some cases.
If the files are sent to me like this, it takes less than an minute to change them with left padding zeros with the multirename tool.
I prefer to keep the actual way of sorting files because I think it could have erratic behaviours in some cases.
Fabio Chelly.
#60241
Lorsqu'on s'occupe d'informatique il faut faire comme les canards...
Paraître calme en surface et pédaler comme un forcené par en dessous
#60241
Lorsqu'on s'occupe d'informatique il faut faire comme les canards...
Paraître calme en surface et pédaler comme un forcené par en dessous
I agree that this topic is not about a must-have feature for TC. But apart from that your statement is quite wrong.DRP535 wrote:You're all asking for a lot of programming work to go into something which is so trivial and minor that it's simply not worth the effort.
Some of the posters (like me) are not really asking the feature to be integrated into TC, but are just discussing a rather new solution to a problem that occurs at different places.
If the feature would be integrated then it would not require a lot of programming, but just integration of existing code. You can follow the second link in the first post to convince yourself.
Well... It seems we speak about different aspects. I don't care about algorithm complexity or man-month needed for implementation. I wrote about good algorithm. Good - means "make sense for user", i.e. my term "natural order" should match to algorithm's term "natural order". You give the very simple sample, where natural means sequence. But even in this case you cannot know where sequence located in filename. But what we have to do when numbers is not part of sequence and just part of name like other letter?. What content of my file with electric scheme ABC_002_013_XYZ.jpg? Version 2 for device with catalog ID "013_XYZ" or version 13 of device number 2. What is "natural order" for filenames that contain date/time information like abc1102 and abc0104? It is hours/minutes or days/month? So...ddofborg wrote:dude, there is nothing to implement. i posted a link, where you can download the algorithm for C!
Very nice! It's means user have to write some rule/sort criteria/comparision function, and thereby write "natural sorting algoritm". So instead of make job for user we found a new job for user!jb wrote:All you have to do is to decide yourself whether you want to sort the non-numeric parts from start (0) to end (length-1) or from end to start. I guess that also the syntax for numeric substrings could be made configurable (including the direction).

Of course, I don't want to start a long discussion, i just want to clarify my opinion - "efforts to implement this feature doesn't match to profit".
PS. Just for fun. In Israel some religious organizations still using letter notation for numbers. Like roman numbers: I,V,L,M,C,X:)
After all you can see it as a measure against unemployment.VadiMGP wrote:Very nice! It's means user have to write some rule/sort criteria/comparision function, and thereby write "natural sorting algoritm". So instead of make job for user we found a new job for user!![]()

No seriously: You did not get the point. I tried to tell you that the "natural sorting algorithm" can probably be localized because you complained that the current algorithm is not appropriate for your region. From your previous posts I glanced over I assumed that you are a kind of programmer.
Last edited by jb on 2003-05-14, 05:46 UTC, edited 1 time in total.
- pdavit
- Power Member
- Posts: 1529
- Joined: 2003-02-05, 21:41 UTC
- Location: Kavala -> Greece -> Europe -> Earth -> Solar System -> Milky Way -> Space
- Contact:
The links provided by ddofborg denote that this idea if far from silly. The first one actually is a .org which we all know what that means!JackFoo wrote:I'm not saying it's difficult, I'm saying that your so-called 'natural' order is not mine, moreover it's silly.

Computers are machines for the aid of humans and every algorithm that has a more meaningful outcome to us should be supported.
Then probably even the current shorting is not reliable for you!VadiMGP wrote:BTW i live in Israel and in hebrew filenames sometimes used right-to-left reading order.

"My only reason for still using M$ Window$ as an OS is the existence of Total Commander!"
Christian Ghisler Rules!!!
Christian Ghisler Rules!!!
"meaningful" is the operative word, and that means consistent and comprehensible and predictable. Every example I've seen of "natural sorting" (NS) is simple and obvious, but that is not real life. TC would have to "naturally sort" all files in all situations, not just the simple ones.Computers are machines for the aid of humans and every algorithm that has a more meaningful outcome to us should be supported.
How would you NS the following cases:
a1.txt, a01.txt, a2.txt
a1.txt, a2.c, a10.txt, a12.c
a1b.txt, a20b.txt, a2c.txt
If you define candidates for NS narrowly enough (i.e., a non-numeric prefix followed by a single numeric suffix and the same exact extension) then I suppose it would be useful in some cases, but IMO if you try to generalize the concept you simply make it impossible to predict what order a given sequence of files will appear in. And even in cases that follow that rule, like my first example above, a1.txt, a01.txt, a2.txt, there simply is no "natural" sequence.