Popup menu items not listed in order

I have a popup menu which lists custom images, however they are not listed in order.
The images are named like skin_001.png to skin_030.png. Instead of being listed in order, the last one listed is skin_008.png.

This worked before but I’m not sure at what version of XOJO it quit working correctly.


they are listed in the order in which you added them to the menu.
If you are just reading a file directory to get the names, they are not guaranteed to be returned in sorted order.

Yeah I get them from a folder. Well I can live it.

Oh well, thanks.

just sort them first

How do I sort them first ?

I have a loop and add folderitem name to the popup menu.

add them to an array… sort the array… add them to your menu

Ah ok I see. thanks.

And I assume you’ve just looped over the FolderItem.Child’s.

What has changed is that Apple switched from the HFS filesystem to APFS.
We used to get the FolderItem.Child’s sorted alphabetically with HFS (even though this has never been guaranteed even then!).
And with APFS, you don’t get them sorted alphabetically (maybe sometimes, but hardly ever / I suspect it’s some other “sort” we get). See also this Thread.

I suspect that’s it’s such an APFS issue you’ve run into - it changes behavior even in “old applications”.
And @Dave S has given you the answer: If you want a list sorted, then do this (on your own). Don’t expect a Framework to do that, unless it states explicitly that it does.

There were a trick (30 years ago or so):

Display the folder by list,
Click view by name (into the a…z order),
Select all,
Move all into its original folder (move the files into its own folder),

and the files appears now in the alphabetical order.

Is this working in APFS ?

Ah didn’t know about that. I could switch it over to a listbox and use sort… if I want to go to all that work. HA! :wink:

Well thanks for all the help.

Or use SortWith…

[code]dim names() as String
Dim items() as folderitem
For i as integer = 1 to folder.count
Items.Append folder.item(I)
Next i

names.sortWith items[/code]

Then loop over items and put them in the pop up menu.