put lists in a dropdown in alphabetical order

Adding new infoboxes through the Admin of an oscommerce cart is laborious enough without having to hunt through an unsorted list of filenames in a dropdown. So this article’s short tip examples one of php’s really useful functions – sort().

This is an unsorted list of infobox files in a dropdown in a Cre Loaded Admin:
screenshot from cre loaded 6.4.1a of unsorted list in dropdown of infobox filenames

Same list now sorted alphabetically:
screenshot of list of filenames sorted alphabetically

The basic code change required to an array:

 $dirs1[] = $file;
            $dirs_array1[] = array('id' => $file1,
                                   'text' => $file1);
          }
        }
        closedir($handle1);
      }

sort($dirs_array1);  // added to sort list alphabetically