You can order them using php's filemtime(): http://php.net/manual/en/function.filemtime.php
<?php
$path = dirname(realpath(__FILE__)).'/pictures/';
$handle = opendir($path);
$arrFiles = array();
while($file = readdir($handle))
{
if($file !== '.' && $file !== '..')
{
$arrFiles[filemtime($path.$file)] = '<a href="pictures/'.$file.'" rel="lightbox"><img src="pictures/'.$file.'" border="0" /></a>';
}
}
arsort($arrFiles);
foreach ($arrFiles as $file)
{
echo $file;
}
?>