FOLDER LIST and DOCUMENT LIST unsorted

An other thing with a high side effect I discovered 2 years back, and declared 1 year ago to 4D:

<code 4D>
FOLDER LIST($path;$T_folders)
DOCUMENT LIST($path;$T_documents)
</code 4D>

Before, the result was sorted, which is logical. But suddenly, it appears not to be.
Everything was then unsorted, but even with 4D modules too !!!

I discovered this with the resources manager in 4D: folders and files were no more sorted. Very frustrating, and this is one of the reasons, seeing nothing changes (even in v18), I wrote 4DPop Resources Buddy.
Obviously, all my folders and files managers were unsorted too.
But recently, I was asking myself about the strange illogical order of 4DPop components in the palette: Oh yes, for sure, same trouble. So yesterday, I had to add everywhere a sort in 4DPop itself, which gives now a predictable order for componentsSad

<code 4D>
FOLDER LIST($path;$T_folders)
SORT ARRAY($T_folders)
DOCUMENT LIST($path;$T_documents)
SORT ARRAY($T_documents)
</code 4D>

This is a very bad side effect, as it touches plenty of things, even 4D itself.
I began to change everywhere it is used, so my question to 4D:

Is it intentional ? I mean you decided to gain a little time by giving unsorted result ?
Is it a bug ? And if yes, will you repair it one day or not ?

Then we will have plenty of unnecessary sorts in code: yours, and ours…

IMHO I wouldn’t write my code expecting these lists are sorted. If needed I sort the way I need. For example I have a batch method that has to work with documents in a folder, the “right” order is anti chronological (older first). Finder allows many different way to sort, too. Didn’t try, but I would not expect that commands from “Files and Folders” return ordered values, BTW.

The 64-bit Mac version now uses POSIX API for files and folders, which is much faster than the classic carbon API.

https://speakerdeck.com/miyako/huairusisutemu-4d-world-tour-2019-2ri-mu-yori?slide=2

The change was made in v16 R5.

You suspect that 4D “decided to gain a little time by giving unsorted result”, but I think 4D never sorted the result, it was just passing the result from the underlying API.

After all, sorting file names is a subjective concept. For instance, https://developer.apple.com/documentation/foundation/nsarray/1408213-sortedarrayusingfunction?language=objcFinder sorts in a specific way> so that “item 10” comes after “item 9” and not before “item 2”.

better link: https://developer.apple.com/documentation/foundation/nsstringcompareoptions/nsnumericsearch

I agree with all of you !

What I want to figure out is the fact that 4D never changes this kind of wrong behavior in its Tools box / Resources, and in 4D pop too… And when unsorted, this is so painful to just use them.

Anyway, you seem to say I don’t have to wait for any changes for those commands and you are right.
I’ll use new modern commands now.

I’ll post a new 4DPop for v17 with some corrections in that way, for who needs…

Ok published.

https://www.protee.org/index.php/en/download-en/4d-free-bonus

You’ll find “4DPop v17 version og” and “4D Pop Resources Buddy” to correct the unsorted result of the commands.