title: Sorting XML File into ascending order using php
body: <p>i have an xml file which contains around 60 books which i need to put into ascending order from the borrowedcount using php so far my code shows all the books but will not sort? any help would be really appriecated </p>
  
  <p><strong>PHP</strong></p>
  
  <pre><code>&lt;?php
  
  
  $xmlassignDoc = new DOMDocument();
  $xmlassignDoc-&gt;load("books.xml");
  
  
  $books = $xmlBookDoc-&gt;getElementsByTagName("item");
  
  foreach($books as $list)
  {
      $course = $list-&gt;getElementsByTagName("course");
      $course = $course-&gt;item(0)-&gt;nodeValue;
  
  
  //HERE is where the GET function will be
      if ($course == "CC150")
      {
  
      print_r($array);
          $id = $list-&gt;getAttribute("id");
          echo "&lt;b&gt;Book ID: &lt;/b&gt; $id &lt;br&gt;";
  
           $title = $list-&gt;getElementsByTagName("title");
           $title = $title-&gt;item(0)-&gt;nodeValue;
           echo "&lt;b&gt;Title: &lt;/b&gt; $title &lt;br&gt;";
  
           $isbn = $list-&gt;getElementsByTagName("isbn");
           $isbn = $isbn-&gt;item(0)-&gt;nodeValue;
           echo "&lt;b&gt;ISBN: &lt;/b&gt; $isbn &lt;br&gt;";
  
           $borrowed = $list-&gt;getElementsByTagName("borrowedcount");
           $borrowed = $borrowed-&gt;item(0)-&gt;nodeValue;
           echo "&lt;b&gt;Borrowed Count: &lt;/b&gt; $borrowed &lt;br&gt;";
           echo "&lt;br&gt;";
      } 
  }
  //print $xmlBookDoc-&gt;saveXML();
  ?&gt;
  </code></pre>
  
  <p><strong>xml file</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;bookcollection&gt;
  &lt;items&gt;
    &lt;item id="51390"&gt;
       &lt;title&gt;Management of systems development /&lt;/title&gt;
       &lt;isbn&gt;0091653215&lt;/isbn&gt;
       &lt;url&gt;http://library.hud.ac.uk/catlink/bib/51390&lt;/url&gt;
       &lt;borrowedcount&gt;45&lt;/borrowedcount&gt;
       &lt;courses&gt;
          &lt;course&gt;CC140&lt;/course&gt;
          &lt;course&gt;CC210&lt;/course&gt;
       &lt;/courses&gt;
    &lt;/item&gt;
    &lt;item id="483"&gt;
       &lt;title&gt;Database systems management and design /&lt;/title&gt;
       &lt;isbn&gt;0877091153&lt;/isbn&gt;
       &lt;url&gt;http://library.hud.ac.uk/catlink/bib/483&lt;/url&gt;
       &lt;borrowedcount&gt;28&lt;/borrowedcount&gt;
       &lt;courses&gt;
          &lt;course&gt;CC140&lt;/course&gt;
       &lt;/courses&gt;
    &lt;/item&gt;
    &lt;item id="585842"&gt;
       &lt;title&gt;E-learning skills /&lt;/title&gt;
       &lt;isbn&gt;0230573126&lt;/isbn&gt;
       &lt;url&gt;http://library.hud.ac.uk/catlink/bib/585842&lt;/url&gt;
       &lt;borrowedcount&gt;5&lt;/borrowedcount&gt;
       &lt;courses&gt;
          &lt;course&gt;CC157&lt;/course&gt;
       &lt;/courses&gt;
    &lt;/item&gt;
  </code></pre>
  
  <p>
  </p>