<![CDATA[ Can MCPUCK organize files alphabetically - My Forums]]> https://forums.modx.com/thread/?thread=46385 <![CDATA[Re: Can MCPUCK organize files alphabetically]]> https://forums.modx.com/thread/46385/can-mcpuck-organize-files-alphabetically#dis-post-268237 Quote from: AntonL at Jul 31, 2008, 02:22 PM

I thought this would driven more people crazy long before now!

It’s certainly started to get on my nerves recently, up until now I haven’t use the image browser, but it was the first thing I noticed about it. Your hack works fine on 0.9.6.2-rc2.]]>
Pandy06269 Aug 17, 2008, 09:00 AM https://forums.modx.com/thread/46385/can-mcpuck-organize-files-alphabetically#dis-post-268237
<![CDATA[Re: Can MCPUCK organize files alphabetically]]> https://forums.modx.com/thread/46385/can-mcpuck-organize-files-alphabetically#dis-post-268236
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:
natcasesort($files);


Add this:
$files = array_values($files);


And finally, at long last, the file names are alphabetically sorted. smiley

I thought this would driven more people crazy long before now!]]>
AntonL Jul 31, 2008, 09:22 AM https://forums.modx.com/thread/46385/can-mcpuck-organize-files-alphabetically#dis-post-268236
<![CDATA[Re: Can MCPUCK organize files alphabetically]]> https://forums.modx.com/thread/46385/can-mcpuck-organize-files-alphabetically#dis-post-268235 http://modxcms.com/forums/index.php?topic=19411.0
]]>
ganeshXL Jul 30, 2008, 11:09 AM https://forums.modx.com/thread/46385/can-mcpuck-organize-files-alphabetically#dis-post-268235
<![CDATA[Re: Can MCPUCK organize files alphabetically]]> https://forums.modx.com/thread/46385/can-mcpuck-organize-files-alphabetically#dis-post-268234
0.9.6.2-rc1
rev 3708]]>
AntonL Jul 30, 2008, 10:22 AM https://forums.modx.com/thread/46385/can-mcpuck-organize-files-alphabetically#dis-post-268234
<![CDATA[Re: Can MCPUCK organize files alphabetically]]> https://forums.modx.com/thread/46385/can-mcpuck-organize-files-alphabetically#dis-post-268233 AntonL Jun 30, 2008, 08:37 PM https://forums.modx.com/thread/46385/can-mcpuck-organize-files-alphabetically#dis-post-268233 <![CDATA[Re: Can MCPUCK organize files alphabetically]]> https://forums.modx.com/thread/46385/can-mcpuck-organize-files-alphabetically#dis-post-268232 KniteRiter May 23, 2008, 11:13 AM https://forums.modx.com/thread/46385/can-mcpuck-organize-files-alphabetically#dis-post-268232 <![CDATA[Re: Can MCPUCK organize files alphabetically]]> https://forums.modx.com/thread/46385/can-mcpuck-organize-files-alphabetically#dis-post-268231 quietly sitting as an RC1 release ... it’s solved a lot of problems for me actually.]]> rethrash May 23, 2008, 10:55 AM https://forums.modx.com/thread/46385/can-mcpuck-organize-files-alphabetically#dis-post-268231 <![CDATA[Can MCPUCK organize files alphabetically]]> https://forums.modx.com/thread/46385/can-mcpuck-organize-files-alphabetically#dis-post-268230 KniteRiter May 23, 2008, 10:51 AM https://forums.modx.com/thread/46385/can-mcpuck-organize-files-alphabetically#dis-post-268230