[pmwiki-users] attachlist sorting

Patrick R. Michaud pmichaud at pobox.com
Wed Mar 29 15:14:11 CST 2006

On Wed, Mar 29, 2006 at 05:23:24PM +0100, Hans wrote:
> scripts/uploads.php has in function FmtUploadList:
>     asort($filelist);
> ...
> Dropping the code line  asort($filelist);
> results in an alphabetical list where upper and lower case names are
> mixed (at least it appears to me that way). I find this more
> desirable, and easier to locate filenames, as the first letter case is
> not so important, or not known.
> I wonder if the asort($filelist) can be omitted, or am I missing
> something vital in its presence?

Short answer:  If the asort() is omitted, then for many environments
the list of attachments won't be in any useful order.

Longer explanation:

If the asort($filelist) is omitted, then the results aren't
sorted -- they'll be in whatever sequence the operating system
returns them.  If they're appearing to be sorted on your system, 
I'd be willing to bet that's because they were copied or uploaded
into the uploads/ folder in alphabetical order, and the 
operating system just happens to return them in the same order
as they were placed in the uploads folder.  (This is very likely
if the files were placed there using an FTP program or a
Unix "cp * uploads" or "mv * uploads" command.)

It's also possible that the filesystem is internally
keeping the directory in alphabetical order, if that's the
case it would also explain why the files appear to be sorted
even when asort() is omitted.

But in the general case, omitting the asort() will result in
the files being in no useful order.

I can see about providing the wikiadministrator with an option
to use a different sort criteria than the default asort(), if
that helps.


More information about the pmwiki-users mailing list