Sorting XML output
<p>Here is the PHP im using to read XML:</p>

<pre><code>            $url = "images.xml";
            $xmlstr = file_get_contents($url);
            $xml = new SimpleXMLElement($xmlstr);               
            foreach ($xml-&gt;image as $image) {
                $id = $image-&gt;id;
                $link =  $image-&gt;href;
                $src = $image-&gt;source;
                $title = $image-&gt;title;
                $alt = $image-&gt;alt;
                echo "&lt;a href='$link'&gt;&lt;img src='$src' alt='$alt' title='$title' /&gt;&lt;/a&gt;";
            }
</code></pre>

<p>The XML contains an ID: <code>$id = $image-&gt;id;</code></p>

<p>I need to sort the output by that ID. How can I do this within the foreach?</p>
