title: SQL: sorting child rows under parent row
body: <p>I have this table in my SQL Server database. </p>
  
  <pre><code>MenuID  MenuText    ParentMenu     MenuOrder        MenuLevel
  -------------------------------------------------------------
  1   Home                0              1                0
  2   Administrator       0              2                0
  3   Groups              2              1                1
  4   Users               2              2                1
  5   Permissions         2              3                1
  6   Test Level2         3              1                2
  7   Test Level3         6              1                3
  </code></pre>
  
  <p>I want to sort this table rows like this: </p>
  
  <ul>
  <li><code>Home</code>, <code>Administrator</code> are MenuLevel 0 items. </li>
  <li>MenuLevel 1 items will be under its top level menus according to their <code>ParentMenu</code> column which points to the parent <code>MenuID</code>. The child items will be sorted according to their <code>MenuOrder</code> column. </li>
  </ul>
  
  <p>I tried so many things, but couldn't get the idea how it will be done using query.</p>