title: sort results from external website
body: <p>I'm displaying sporting fixtures from an external site using curl and absolute links which works well. Problem is that the external site doesn't sort the results correctly. Could I do this maybe referring to the tags of the external page.</p>
  
  <p>This my code: </p>
  
  <pre><code>&lt;?php
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, "http://www.sportingpulse.com/mobile/mobile.cgi?a=CL&amp;aID=2307");
  curl_setopt($ch, CURLOPT_HEADER, 0);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
  $result = curl_exec($ch);
  curl_close($ch);
  $result = preg_replace("#(&lt;\s*a\s+[^&gt;]*href\s*=\s*[\"'])(?!http)([^\"'&gt;]+)([\"'&gt;]+)#",'$1http://www.sportingpulse.com/mobile/$2$3', $result);
  echo $result
  ?&gt;
  </code></pre>
  
  <p>This is the results I'd like sorted by age group (maybe using class="list-name") or any other suggestions: </p>
  
  <pre><code>        &lt;ul class="options" data-role="listview"&gt;
  &lt;li role="heading" data-role="list-divider"&gt;Please choose your Competition&lt;/li&gt;
        &lt;li&gt;&lt;a href="http://www.sportingpulse.com/mobile/mobile.cgi?a=CF&amp;amp;aID=2307&amp;amp;cID=223601"&gt;&lt;div class="list-name"&gt;2012 Winter 23 Girls A&lt;/div&gt;&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href="http://www.sportingpulse.com/mobile/mobile.cgi?a=CF&amp;amp;aID=2307&amp;amp;cID=223608"&gt;&lt;div class="list-name"&gt;2012 Winter 18 Boys A&lt;/div&gt;&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href="http://www.sportingpulse.com/mobile/mobile.cgi?a=CF&amp;amp;aID=2307&amp;amp;cID=223691"&gt;&lt;div class="list-name"&gt;2012 Winter 23 Girls AR&lt;/div&gt;&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href="http://www.sportingpulse.com/mobile/mobile.cgi?a=CF&amp;amp;aID=2307&amp;amp;cID=223637"&gt;&lt;div class="list-name"&gt;2012 Winter 18 Boys AR&lt;/div&gt;&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href="http://www.sportingpulse.com/mobile/mobile.cgi?a=CF&amp;amp;aID=2307&amp;amp;cID=223578"&gt;&lt;div class="list-name"&gt;2012 Winter 18 Boys B&lt;/div&gt;&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href="http://www.sportingpulse.com/mobile/mobile.cgi?a=CF&amp;amp;aID=2307&amp;amp;cID=223711"&gt;&lt;div class="list-name"&gt;2012 Winter 23 Girls B&lt;/div&gt;&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href="http://www.sportingpulse.com/mobile/mobile.cgi?a=CF&amp;amp;aID=2307&amp;amp;cID=223620"&gt;&lt;div class="list-name"&gt;2012 Winter 18 Boys BR&lt;/div&gt;&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href="http://www.sportingpulse.com/mobile/mobile.cgi?a=CF&amp;amp;aID=2307&amp;amp;cID=223661"&gt;&lt;div class="list-name"&gt;2012 Winter 18 Girls BR&lt;/div&gt;&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href="http://www.sportingpulse.com/mobile/mobile.cgi?a=CF&amp;amp;aID=2307&amp;amp;cID=223573"&gt;&lt;div class="list-name"&gt;2012 Winter 18 Boys C&lt;/div&gt;&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href="http://www.sportingpulse.com/mobile/mobile.cgi?a=CF&amp;amp;aID=2307&amp;amp;cID=223639"&gt;&lt;div class="list-name"&gt;2012 Winter 23 Girls BR&lt;/div&gt;&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href="http://www.sportingpulse.com/mobile/mobile.cgi?a=CF&amp;amp;aID=2307&amp;amp;cID=223679"&gt;&lt;div class="list-name"&gt;2012 Winter 23 Girls C&lt;/div&gt;&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href="http://www.sportingpulse.com/mobile/mobile.cgi?a=CF&amp;amp;aID=2307&amp;amp;cID=223676"&gt;&lt;div class="list-name"&gt;2012 Winter 20 Boys A&lt;/div&gt;&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href="http://www.sportingpulse.com/mobile/mobile.cgi?a=CF&amp;amp;aID=2307&amp;amp;cID=223579"&gt;&lt;div class="list-name"&gt;2012 Winter 20 Boys AR&lt;/div&gt;&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href="http://www.sportingpulse.com/mobile/mobile.cgi?a=CF&amp;amp;aID=2307&amp;amp;cID=223686"&gt;&lt;div class="list-name"&gt;2012 Winter 23 Boys A&lt;/div&gt;&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href="http://www.sportingpulse.com/mobile/mobile.cgi?a=CF&amp;amp;aID=2307&amp;amp;cID=223592"&gt;&lt;div class="list-name"&gt;2012 Winter 20 Boys B&lt;/div&gt;&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href="http://www.sportingpulse.com/mobile/mobile.cgi?a=CF&amp;amp;aID=2307&amp;amp;cID=223704"&gt;&lt;div class="list-name"&gt;2012 Winter 23 Boys AR&lt;/div&gt;&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href="http://www.sportingpulse.com/mobile/mobile.cgi?a=CF&amp;amp;aID=2307&amp;amp;cID=223662"&gt;&lt;div class="list-name"&gt;2012 Winter 23 Boys B&lt;/div&gt;&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href="http://www.sportingpulse.com/mobile/mobile.cgi?a=CF&amp;amp;aID=2307&amp;amp;cID=223685"&gt;&lt;div class="list-name"&gt;2012 Winter 23 Boys BR&lt;/div&gt;&lt;/a&gt;&lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>