Nearly! Thanks for pointing me in the right direction.
It turns out that the sort() function had been replaced by natcasesort() in recent 0962 revisions. The problem with natcasesort() (and natsort()) is that it maintains the key-value relationships and this means that the for-loop was iterating through the array in numerical key order (i.e. unsorted!), instead of the order of the just-sorted values.
A for-each loop should work, but I followed the advice from a comment on the PHP docs (
http://us2.php.net/manual/en/function.natcasesort.php#32610): The array_values() function can be used to reset the numerical keys to the sequential order of the just-sorted values.
In /manager/media/browser/mcpuk/connectors/php/Commands/GetFoldersAndFiles.php
Underneath the line:
Add this:
$files = array_values($files);
And finally, at long last, the file names are alphabetically sorted.
I thought this would driven more people crazy long before now!