Page 1 of 1

any reason not to add a "sort()" call in create_file_dropdown()?

Posted: Tue Oct 12, 2010 12:12 am
by codegrunt
Howdy.  I have just started adding some {content_image} boxes in my templates and noticed that there is no sorting being done for filename lists.  Since that tends to make it harder to find what you are looking for (in larger lists especially), I was curious if anyone can think of a reason NOT to add a "sort()" call to this function?

Code: Select all

function create_file_dropdown($name,$dir,$value,$allowed_extensions,$optprefix='',$allownone=false,$extratext='',
                              $fileprefix='',$excludefiles=1)
{
  $files = array();
  $files = get_matching_files($dir,$allowed_extensions,true,true,$fileprefix,$excludefiles);
  if( $files === false ) return false;
        sort($files); // make filelist easier to read
                     $fileprefix='',$excludefiles=1)
      ...
It looks safe to me as it does not appear to expect any specific array index association but thought I would ask in case I am not seeing something.

Cheers

Re: any reason not to add a "sort()" call in create_file_dropdown()?

Posted: Tue Oct 12, 2010 2:25 am
by Dr.CSS
No reason...

But you may want to files these under the Feature Request board, and you can submit these as feature request for the core http://dev.cmsmadesimple.org/feature_request/list/6 and you can also talk to the developers on IRC #cms about diff. files for patches...