I added a bunch of empty subfolders to a parent folder. Most use a unique single character as their name (including a space). I duplicated several folders in the Finder using Command + D.
The subfolders are sorted by name in the Mac Finder as shown in the left column of the images.
The right column shows the names of the folders as obtained with a loop using the parent folder’s index value.
This has the appearance of the parent using a file index based upon an array of sub arrays.
The sub arrays are based upon the first character of the file and are sorted alphabetically.
The sub arrays are sorted alphabetically. The main array is not sorted alphabetically but according to a hierarchy established by Apple for unknown reasons.
If I create five folders starting with these five characters in any parent folder they will always be returned in this order via the index property.
[space ] Index 1
! Index 2
" Index 3
Index 4
$ Index 5
If I duplicate the folder named " its now has the index of 4.
Files beginning with a space are one sub array while those beginning with a ! are another sub area. The space sub array is always first followed by the sub array for ! and so on.
[space ] Index 1
! Index 2
" Index 3
" copy Index 4
Index 5
$ Index 6
Is this how MacOS is creating folder indexes and why Xojo is returning such values?
This post indicates they used to be returned alphabetically before APFS.