Natural Order Sorting

English support forum

Moderators: Hacker, petermad, Stefan2, white

ddofborg
Junior Member
Junior Member
Posts: 30
Joined: 2003-05-12, 15:11 UTC
Location: Netherlands
Contact:

Post by *ddofborg »

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!
Free fast image hosting: http://picserver.org/
User avatar
JackFoo
Senior Member
Senior Member
Posts: 373
Joined: 2003-02-05, 19:53 UTC
Location: ERROR

Post by *JackFoo »

"Lasciate Ogni Speranza Voi Ch'entrate", and so do I.

(I'm done with this thread)

Cheers.
jb
Senior Member
Senior Member
Posts: 412
Joined: 2003-02-09, 22:56 UTC
Location: Switzerland

Post by *jb »

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? :lol: I think is much more easy to use standard sorting and zero-leading padding.
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).
ddofborg
Junior Member
Junior Member
Posts: 30
Joined: 2003-05-12, 15:11 UTC
Location: Netherlands
Contact:

Post by *ddofborg »

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/
jb
Senior Member
Senior Member
Posts: 412
Joined: 2003-02-09, 22:56 UTC
Location: Switzerland

Post by *jb »

ddofborg wrote:well, the algorithm is a bit more complicated, because 1.10 also goes after 1.9 in it...
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:TC is written in Delphi, right?
Yes.
User avatar
Grave
Junior Member
Junior Member
Posts: 31
Joined: 2003-05-04, 21:14 UTC
Location: Slovakia

Post by *Grave »

would be great, i had to use 0 padding numerous times because of that static sorting order (1 10 11 2 etc)
Grave
*eat people, not animals*
User avatar
DRP535
Senior Member
Senior Member
Posts: 305
Joined: 2003-03-03, 11:25 UTC

Post by *DRP535 »

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.
User avatar
fabiochelly
Power Member
Power Member
Posts: 603
Joined: 2003-02-05, 12:03 UTC
Location: Rambouillet, France

Post by *fabiochelly »

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.
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
jb
Senior Member
Senior Member
Posts: 412
Joined: 2003-02-09, 22:56 UTC
Location: Switzerland

Post by *jb »

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.
I agree that this topic is not about a must-have feature for TC. But apart from that your statement is quite wrong.
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.
VadiMGP
Power Member
Power Member
Posts: 672
Joined: 2003-04-05, 12:11 UTC
Location: Israel

Post by *VadiMGP »

ddofborg wrote:dude, there is nothing to implement. i posted a link, where you can download the algorithm for C!
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...
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).
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! :wink:

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:)
jb
Senior Member
Senior Member
Posts: 412
Joined: 2003-02-09, 22:56 UTC
Location: Switzerland

Post by *jb »

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! :wink:
After all you can see it as a measure against unemployment. :wink:
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.
jb
Senior Member
Senior Member
Posts: 412
Joined: 2003-02-09, 22:56 UTC
Location: Switzerland

Post by *jb »

Sorry, this post was a duplicate of the previous one. By mistake I pressed the quote button instead of the edit button.
Last edited by jb on 2003-05-14, 05:46 UTC, edited 1 time in total.
VadiMGP
Power Member
Power Member
Posts: 672
Joined: 2003-04-05, 12:11 UTC
Location: Israel

Post by *VadiMGP »

jb wrote:From your previous posts I glanced over I assumed that you are a kind of programmer.
Yes, I am. :) And i prefer to spend my time to writing some plugin or addon for TC. :wink:
User avatar
pdavit
Power Member
Power Member
Posts: 1529
Joined: 2003-02-05, 21:41 UTC
Location: Kavala -> Greece -> Europe -> Earth -> Solar System -> Milky Way -> Space
Contact:

Post by *pdavit »

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.
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! :D

Computers are machines for the aid of humans and every algorithm that has a more meaningful outcome to us should be supported.
VadiMGP wrote:BTW i live in Israel and in hebrew filenames sometimes used right-to-left reading order.
Then probably even the current shorting is not reliable for you! ;)
"My only reason for still using M$ Window$ as an OS is the existence of Total Commander!"
Christian Ghisler Rules!!!
chasbas
Junior Member
Junior Member
Posts: 52
Joined: 2003-02-06, 16:01 UTC
Location: New Jersey

Post by *chasbas »

Computers are machines for the aid of humans and every algorithm that has a more meaningful outcome to us should be supported.
"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.

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.
Post Reply