Copy link to clipboard
In Lightroom Classic a friend came accross a weird bug (LR Classic 11.3.1 (Monterey 12.3.1). I tested the bug also with LR 10.4 (Mojave)), when importing a series of folder with numerical values which may include a leading 0.
As you can see in the screenshot attached the order does seem neither numerical nor alphabetical, oddly if you modify a name (or add a folder) the order of the other may change.
Repro steps :
- create a "test" folder
- create a series of folder inside that folder named "1","01","2","02","3","03" (notice how the order of the folders change as you add folder "2").
- the results is an strange ordering :
- if you change the name of the "02" folder into "02x" the order of the "01","1" is modified :
- should you removed the "x" the order will go back to its original state.
The screen shot illustrate this issue with folder name starting with a letter as when the discovery happened.
Copy link to clipboard
[This post contains formatting and embedded images that don't appear in email. View the post in your Web browser.]
More than you could possibly want to know about this:
When sorting file names and folder names, LR uses an ordering similar to that of Mac Finder and Windows File Explorer. These orderings treat numbers within the names numerically (ignoring leading zeros). But LR's ordering has an obscure bug, breaking comparison ties randomly rather than using a consistent rule.
They first split a name into subsequences of non-digits and digits. E.g. "c02x" is split into three subsequences "c", "02", "x". Then when comparing two names, the subsequences are compared in turn. Subsequences of non-digits are compared lexicographically, while subsequences of digits are treated as whole numbers and compared numerically.
For example, consider the comparison of names "c2" and "c02x". They are first split into subsequences:
c, 02, x
The first subsequences "c" and "c" are compared alphabetically, and they are equal. So the second subsequences "2" and "02" are compared, and since they are both numbers they are compared numerically, and they are equal. The first name has no more subsequences, while the second one has "x", so the first name comes before the second.
Finder, File Explorer, and LR differ in how they handle comparisons of numeric subsequences with leading 0s. It appears that when Finder has two names whose subsequences are equal, it breaks ties by putting the shorter name first (e.g. "c1" before "c01"). Whereas File Explorer breaks ties by comparing the entire names lexicographically (e.g. "c01" before "c1").
But it appears that LR doesn't have a rule for breaking ties and uses whatever order its sort algorithm produces. It looks like the sort algorithm is technically "unstable", meaning that there's no consistency in how ties are handled. That explains why your first screenshot shows "C01" followed by "C1", while the second screenshot shows "C1" followed by "C01".
I think it's a bug that LR's sorting is unstable and breaks ties randomly. But I also know that Adobe will pay zero attention if you file a bug report 😆
An interesting aside: File Explorer sorts file names using the algorithm I described above, but it sorts folder names strictly lexicographically.
Here's a screenshot showing how Finder and File Explorer sort file names, and how LR, Finder, and File Explorer sort folder names:
You confirm my guesses so far including the care taken with bug reports or feature requests here 😅 #PleaseDontAskAboutDescendingOrder
Having worked in the internationalisation field for a few years, I know that collation is all but a simple problem... I was just asking here for a little consistency from Adobe.
Thanks for taking the time to look into it 🙂