Sorting mystery

40 views
Skip to first unread message

Rob

unread,
Apr 3, 2020, 3:07:14 PM4/3/20
to leo-editor
This is not a Leo problem. However, there a lot of very smart people here who might have some insights into this.

I want to name files in an intuitive way so that Windows (and other apps like Adobe Lightroom) sort them properly. Consider these image file names:

1990 0909 image1.jpg (0909 indicates September 9)
1990 1001 image2.jpg
1990 10xx image3.jpg (10xx indicates October with unknown date)

Within Leo, these sort as expected (as above). However, in Windows they sort this way:

1990 10xx ...
1990 0901 ...
1990 0909 ...

This doesn't make any sense! How does 1990 10xx ... have a lower numeric value than 1990 0901 ...? I found this reference on Microsoft's page, but I don't understand it. Does anyone know why this happens and better yet, how to fix it?

Rob...

Thomas Passin

unread,
Apr 3, 2020, 5:54:33 PM4/3/20
to leo-e...@googlegroups.com
It's because 0901 is larger than 10.  The only numerals in "10xx"  are 10.  According to the link you found, it seems like the OS is sorting on the characters that can be considered numeric.  In the older days, the filenames were just sorted alphabetically, it seems.  That carries its own anomalies.

It looks like it is (or used to be) possible to change a registry entry to get the old behavior, but this probably isn't the best idea.  I'd suggest putting dashes between the number groups, which will get closer to what you probably be willing to live with.  It's what I have done for a long time, and I haven't notice my image files coming up in strange orders:

1990-09-01
1990-09-09
1990-10-02
1990-10-30
1990-10-xx
1990-11-01

Using the dashes makes the numerical comparisons to be group-by-group, as best as I can see.  The example above sorted the same when I did a numeric and an alphabetical sort using EditPlus, so that's good too.

It also means that the file names don't have to be quoted if you type them on the command line sometime.

[Later - I just realized that you must be talking about a large number of files that you already have.  So what I said above may be so, but it won't actually be helpful since you wouldn't be renaming all those files from the past.  Sorry!  I think there are file renaming utilities.  Maybe one of them could help.]

Rob

unread,
Apr 4, 2020, 9:33:19 AM4/4/20
to leo-editor
Thanks for the clarification and suggestions, Thomas!

Rob...

Steve Litt

unread,
Feb 26, 2023, 5:58:27 PM2/26/23
to leo-e...@googlegroups.com
Rob said on Fri, 3 Apr 2020 12:07:14 -0700 (PDT)

>This is not a Leo problem. However, there a lot of very smart people
>here who might have some insights into this.
>
>I want to name files in an intuitive way so that Windows (and other
>apps like Adobe Lightroom) sort them properly. Consider these image
>file names:
>
>1990 0909 image1.jpg (0909 indicates September 9)
>1990 1001 image2.jpg
>1990 10xx image3.jpg (10xx indicates October with unknown date)

With numbers like 0909 and 1001, etc, I follow the path of least
resistance and add an impossibly high power of ten, such as a million
(if I never expect it to reach a million. Then all become 7 character
strings with preceding zeros, and they sort the way I want.

SteveT

Steve Litt
Autumn 2022 featured book: Thriving in Tough Times
http://www.troubleshooters.com/bookstore/thrive.htm
Reply all
Reply to author
Forward
0 new messages