<?php
$a=array();
if ($handle = opendir('.')) {
while (false !== ($file = readdir($handle))) {
if(preg_match("/\.doc$/", $file))
$a[]=$file;
}
closedir($handle);
}
sort($a);
foreach($a as $i){
echo $i;
}
?>