Using the below action I gather a list of files and display them. I need to be able to sort the files by last modified date. Is there a simple way in PHP or using ZEND to order the items by last modified? If you know of a easier way to get the files and order them using ZEND; please let me know.
public function imagesAction()
{
$this->_helper->layout->disableLayout();
$results = array();
$handler = opendir(APPLICATION_PATH . '/../public/images/blog');
while ($file = readdir($handler)) {
if ($file != "." && $file != ".." && $file != '.svn') {
$results[] = $file;
}
}
closedir($handler);
$this->view->data = $results;
}
I have tried doing
$this->view->data = ksort($results);
$this->view->data = asort($results);
But those just remove the entire list of files from the view and they stop showing up.