title: How to sort DB records by parent
body: <p>I've DB table like this:</p>
  
  <pre><code>ID    Name    ParentID    isActive
  1      ABC   NULL         true
  2      DEF   1            true
  3      GHI   1            true
  4      JKL   NULL         true
  5      MNO   4            true
  6      PRS   NULL         true
  7      TUV   NULL         true
  8      WX    1            true
  9      YZ    4            true
  10     abc   7            true
  </code></pre>
  
  <p>I get that to a list:</p>
  
  <pre><code>var projectList = connection.Where(d=&gt;d.Active);
  </code></pre>
  
  <p>When I get this table to a list, I want to sort them by parent ID. So, the sorted list should be like this: (each row replaced its parent row's below).</p>
  
  <ul>
  <li><p>1 is parent of 2,3 and 8</p></li>
  <li><p>4 is parent of 5 and 9</p></li>
  </ul>
  
  
  
  <pre><code>1|ABC
  2|DEF
  3|GHI
  **4|WX**
  5|JKL
  6|MNO
  **7|YZ**
  8|PRS
  9|TUV
  **10|abc**
  </code></pre>
  
  <p>How can I sort this list?</p>