title: Codeigniter: unable to show result in desc order with count
body: <p>i have two tables,</p>
  
  <pre><code>instructions 
  -------------
  instruction_id  int(11)   Primary key (Auto_increment)
  instruction      text
  user_id          int(11)    Foreign key
  
  
  instrunctionlike
  -----------------
  instrunction_likeid  int(11)  Primary key (Auto_increment)
  instrunction_id      int(11)  Foreign Key
  </code></pre>
  
  <p>In instructions &amp; in instrunctionlike table there are many rows,
  <em>what i want is to , get the <code>likes</code> count  in desc order from instrunctionlike table.</em>
    <code>eg. select*from  instrunctionlike  order by count(instrunctionlike.instrunction_likeid)...</code></p>
  
  <p>Below is what i tried, but i am confuse how to implement count on rows with desc order.
  Please help me to solve this issue</p>
  
  <pre><code>//-----------------------------------------------------------------------------------
  public function fetch_agreed_desc_order_instruction($limit, $start) { 
       $this-&gt;load-&gt;database(); 
       $this-&gt;db-&gt;limit($limit, $start);
       $this-&gt;db-&gt;join('userdetails', 'userdetails.user_id = instructions.user_id'); 
        $this-&gt;db-&gt;join('instrunctionlike', 'instrunctionlike.instrunction_id = instructions.instruction_id');
       $this-&gt;db-&gt;order_by('instrunctionlike.instrunction_id', 'DESC');
       $this-&gt;db-&gt;group_by("instrunctionlike.instrunction_id"); 
       $query = $this-&gt;db-&gt;get("instructions"); 
      if ($query-&gt;num_rows() &gt; 0) {
          foreach ($query-&gt;result() as $row) {
              $data[] = $row;
          }
          return $data;
      }
      return false; 
   }
  </code></pre>
  
  <p><strong>Sample output:</strong></p>
  
  <pre><code>             instructions                Likes
               .............                78
               .............                66
               .............                56
               .............                34
               .............                12
               .............                 1
               .............                 1
              .............                  0 
  </code></pre>