title: Sorting Database Table with PHP
body: <p>I have a page on an application that allows an administrator to view tables in the database. The section that prints the values is below:</p>
  
  <pre><code>&lt;table&gt;
                  &lt;?php
                      while ( $row = $result-&gt;fetch_array(MYSQLI_NUM) ) 
                          {
                          // build table to display results
                          print( "&lt;tr&gt;" );
  
                          foreach ( $row as $value )          
                          print( "&lt;td&gt;$value&lt;/td&gt;" );
                          print( "&lt;/tr&gt;" );
                          } 
  
                       ?&gt;
                  &lt;/table&gt;
  </code></pre>
  
  <p>This particular table is populated with the names of certain kids, ages, addresses, contact numbers, etc.</p>
  
  <p>I need to enhance this table by sorting both by age and alphabetically (separately).</p>
  
  <p>Keeping efficiency in mind, how can I modify the while loop above to sort the printed data?</p>
  
  <p>Note: The specified table contains no more than 300 results.</p>