PHP sorting

hello guys, long time i haven’t posted.

I create a while loop in which XML files are read from a folder. each XML file has information about a car, like Year, Model, Mileage, etc.

When they are displayed on the page (while loop), they are displayed from oldest to newest. Is there a way I can make them displayed from newest to oldest, sort by Price or sort by Year? I know there is the SORT function, but I read about it and it LOOKS like it only works with arrays.


$handle = opendir($dirAutomobiles);
while(($file=readdir($handle)) !== FALSE) {
if(is_dir($dirAutomobiles . $file)) continue;
if(!eregi(".xml$", $file)) continue;

$automobileFile = simplexml_load_file($dirAutomobiles . $file);

echo $automobileFile->year;
echo $automobileFile->make;
echo $automobileFile->model;
echo $automobileFile->price;
}