title: Ordering mysql result by loop query value
body: <p>I am doing the following</p>
  
  <pre><code>$def = $_GET['def']; if (!$def == 0) {$offset = 'OFFSET '.$def.'';}
  $data1 = mysql_query(
     "SELECT *, DATE(post_modified) as nicedate 
       FROM (`wp_postmeta`) 
       LEFT JOIN (`wp_posts`) ON wp_postmeta.post_id = wp_posts.ID 
       LEFT JOIN (`wp_top_ten`) ON wp_posts.ID = wp_top_ten.postnumber 
       WHERE meta_value='the_value' 
       ORDER BY nicedate DESC LIMIT 16 ".$offset.""
                     ) or die(mysql_error()); 
     while($info = mysql_fetch_array( $data1 ))
  
   { 
     $id = $info['ID']; 
     echo "some stuff";
     $data2 = mysql_query("
                   SELECT SUM(vote) as total_vote, COUNT(*) as total_count 
                   FROM (`wp_gdsr_votes_log`) 
                   WHERE id='".$id."' AND vote_type='article'
                      ")  or die(mysql_error()); 
          while($info = mysql_fetch_array( $data2 ))
       {$vote = number_format(
              ($info['total_vote']/$info['total_count'])
                          , 2, '.', ' ');} 
               echo $vote."/5"; echo "some more stuff"; 
   } 
  </code></pre>
  
  <p>How could I order the results in <code>$data1</code> where 'nicedate' would be the<code>$vote</code> value ?</p>