title: php SimpleXML sort data key and value. Need to find top 10 values
body: <p>I have an XML file that has the following data in…</p>
  
  <pre><code>&lt;posts&gt;
    &lt;post id="22359"&gt;
      &lt;postviews&gt;31&lt;/postviews&gt;
    &lt;/post&gt;
    &lt;post id="20963"&gt;
      &lt;postviews&gt;1&lt;/postviews&gt;
    &lt;/post&gt;
    &lt;post id="20595"&gt;
      &lt;postviews&gt;3&lt;/postviews&gt;
    &lt;/post&gt;
    &lt;post id="22640"&gt;
      &lt;postviews&gt;72&lt;/postviews&gt;
    &lt;/post&gt;
    &lt;post id="22227"&gt;
      &lt;postviews&gt;1&lt;/postviews&gt;
    &lt;/post&gt;
  ...etc etc
  &lt;/posts&gt;
  </code></pre>
  
  <p>I'd like to find the top 10 highest postview values and then get the parent node post id so I'd essentially have the id's of the top 10 postviews.</p>
  
  <p>I have no idea how to go about this, can anyone help? Is the XML file already an array if I load it via…</p>
  
  <pre><code>$xml = simplexml_load_file($xmlFile);
  </code></pre>
  
  <p>Thanks, James</p>