title: sql complex order by multiple fields
body: <p>I have a <code>table</code> category that has an <code>int</code> field that can reference the <code>primary key</code> in the same table. </p>
  
  <p>like this:</p>
  
  <pre><code>ID category         isSubCategoryOf orderingNumber
  3  "red t-shirts"         2              2 
  1  "clothes"             NULL            1
  4  "cars"                NULL            1
  6  "Baby toys"            5              1
  5  "Toys"                NULL            1
  2  "t-shirt"              1              1
  </code></pre>
  
  <p>I want the <code>table</code> to be order such that under each category all sub-categories are listed and under that category all of that sub-category.</p>
  
  <pre><code>ID category         isSubCategoryOf orderingNumber
  1  "clothes"             NULL            1
  2  "t-shirt"              1              1
  3  "red t-shirts"         2              2 
  4  "cars"                NULL            1
  5  "Toys"                NULL            1
  6  "Baby toys"            5              1
  </code></pre>
  
  <p>Is such a thing possible to do with <code>SQL</code> or do I have to order this later by hand?</p>