Its not the *only* way to do it, but it sure is the most pleasant way to do it (PHP wise). IMO the cost of an additional loop and memory is well worth the ease of operation.
This is a simple method of collecting your items from your first loop, then sorting, than iterating again to output.
function sortByDateTime($a, $b)
return (isset($a->matchname['dateandtime'], $b->matchname['dateandtime']) ? ($a->matchname['dateandtime'] - $b->matchname['dateandtime']) : 0);
$aItems = array();
foreach ($newresult as $newmatchlist)
$aItems = $newmatchlist;
Then iterate the $aItems. Untested, but works alright upstairs.
Alternatively, since you are using XPATH you may want to consider the use of the xpath sort. I don't think I've ever used this before myself, but it looks like it would simply take your node, and then sort it based on a pattern provided (such as the path to another node relative). If you have the proper versions, I'd suggest that would work out perfectly.