みなさん、ありがとうございます。

結局usortを使い
function new_sort($xx , $yy){
$xx1 = date("mdHis",filemtime($xx));
$yy2 = date("mdHis",filemtime($yy));
if($xx1 > $yy2){ return -1;}
elseif($xx1 == $yy2){ return 0;}
else{ return 1;}
}

usort($allfile ,"new_sort");
foreachでまわす前に
としてみたのですが、効率わるいですかね?