It is currently October 27th, 2024, 3:22 pm

Natural sorting please...

Get help with installing and using Rainmeter.
User avatar
jsmorley
Developer
Posts: 22891
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Natural sorting please...

Post by jsmorley »

It's important that you understand what is meant by lexicography sorting alphabetically.

As I mentioned,

m2Name
m22Name
m222Name

Would NOT sort in that order. It would sort as:

m222Name
m22Name
m2Name

Since "2" would sort before "N". The entire string is considered in the sorting, not just the numbers.

I can't help any more than this. The way Rainmeter / FileView sorts is entirely correct using lexicography sorting.
User avatar
Yincognito
Rainmeter Sage
Posts: 8576
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Natural sorting please...

Post by Yincognito »

It isn't the norm because that's how string are compared in all programs: from left to right, and from the lowest char code to the highest. Whatever programs that seem to do otherwise, e.g. Windows Explorer, they don't: they actually space pad numbers internally. So, the only question here really is... who should do the padding needed for the desired order, the users or the devs. :confused:
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
sl23
Posts: 1839
Joined: February 17th, 2011, 7:45 pm
Location: a Galaxy S7 far far away

Re: Natural sorting please...

Post by sl23 »

I can see that now, but you confused me the way you first posted.
Alphabetical sorting is machine sorting and perform on a column basis, not numerical linear basis. ie, it doesn't take into account what the following digit is.

Natural sorting does. Hence why I posted asking for that. Your original reply caused the confusion! :x :sly:

Ok, so now we're both clear... :oops: :Whistle
Is there a way to have Natural sorting without zero padding? It's really annoying and awkward trying to find stuff as my pics show.
57686174 77696C6C 6265 77696C6C 6265
User avatar
sl23
Posts: 1839
Joined: February 17th, 2011, 7:45 pm
Location: a Galaxy S7 far far away

Re: Natural sorting please...

Post by sl23 »

Yincognito wrote: September 22nd, 2024, 2:57 pm It isn't the norm because that's how string are compared in all programs: from left to right, and from the lowest char code to the highest. Whatever programs that seem to do otherwise, e.g. Windows Explorer, they don't: they actually space pad numbers internally. So, the only question here really is... who should do the padding needed for the desired order, the users or the devs. :confused:
Well, that was what I was requesting, that it be done internally, and it turned into a big debate! :rofl:
Seriously though, Can we please have the option in the Rainmeter settings for this? Low priority or not, it would be nice for it to be a consideration and eventually added. :thumbup:
57686174 77696C6C 6265 77696C6C 6265
User avatar
jsmorley
Developer
Posts: 22891
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Natural sorting please...

Post by jsmorley »

Implementing true "nature sorting" is not trivial. There are some libraries out there that deal with the complexities of stuff like "case", "non-ascii characters", and all that, but I'm not sure how easy it would be to shoehorn that into Rainmeter and FileView, and if there would be "backwards compatibility" issues to consider.

Again, I just don't see this as a high priority. Zero-padding numbers in strings is cumbersome, but works.
User avatar
SilverAzide
Rainmeter Sage
Posts: 2753
Joined: March 23rd, 2015, 5:26 pm

Re: Natural sorting please...

Post by SilverAzide »

You kids today... :uhuh:
This is why the only proper character set is the ASCII character set, and the only proper sort order is ASCII order.

/jk
Gadgets Wiki GitHub More Gadgets...
User avatar
jsmorley
Developer
Posts: 22891
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Natural sorting please...

Post by jsmorley »

SilverAzide wrote: September 22nd, 2024, 3:06 pm You kids today... :uhuh:
This is why the only proper character set is the ASCII character set, and the only proper sort order is ASCII order.

/jk
Yeah, but even ASCII has some issues with Natural Sorting:

a
B
A
b

Would sort as:

A
B
a
b

Since "case" is considered in sorting algorithms.

Notepad++ has gone to great lengths to deal with this:

1.jpg
You do not have the required permissions to view the files attached to this post.
User avatar
SilverAzide
Rainmeter Sage
Posts: 2753
Joined: March 23rd, 2015, 5:26 pm

Re: Natural sorting please...

Post by SilverAzide »

jsmorley wrote: September 22nd, 2024, 3:09 pm Would sort as:

A
B
a
b

Since "case" is considered in sorting algorithms.
That's not really a "problem", per se, that's the "correct way". ;-)
This is why we need to go back to uppercase 8.3 filenames.

/jk (again)
Gadgets Wiki GitHub More Gadgets...
User avatar
Yincognito
Rainmeter Sage
Posts: 8576
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Natural sorting please...

Post by Yincognito »

By the way, I personally ALWAYS name my numbered files by zero padding, since Total Commander (the file manager I use) uses the same lexicographic order. The nice thing is that it has multiple / mass renaming, so if not zero padded already, it can be done in like one or two second or such, for as many files as needed.

So, you see, it's not only a Rainmeter thing. If it was trivial, all programs would do it. When the number is at the start or end of the string it very slightly becomes easier, but one would still need a proper solid algorithm to do it.
A job for the incompetent, and NOT even "artificially" intelligent ChatGPT... :twisted:
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
jsmorley
Developer
Posts: 22891
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Natural sorting please...

Post by jsmorley »

SilverAzide wrote: September 22nd, 2024, 3:15 pm That's not really a "problem", per se, that's the "correct way". ;-)
This is why we need to go back to uppercase 8.3 filenames.

/jk (again)
RAINME~1