title: Order by in MySQL for multiple columns
body: <p>I've four columns <code>sale date 4</code>,<code>sale date 3</code>,<code>sale date 2</code>,<code>sale date</code> in my table which are all sale dates. While displaying in page <code>sale date 4</code> is given first priority if it is not empty we are displaying it and if it is empty then comes <code>sale date 3</code> and then <code>sale date 2</code> and then <code>sale date</code>.</p>
  
  <p>My problem is while sorting the results.</p>
  
  <p>When is run the query with order by</p>
  
  <pre><code>order by 
  isnull(`sale date 4`), trim(`sale date 4`) , 
  isnull(`sale date 3`), trim(`sale date 3`) , 
  isnull(`sale date 2`), trim(`sale date 2`) , 
  isnull(`sale date`), trim(`sale date`) asc
  </code></pre>
  
  <p>I'm getting results as follows</p>
  
  <pre><code>**sale date 4** | **sale date 3**  | **sale date 2** | **sale date**
  --------------------------------------------------------------------
  2013-01-24      | 2013-01-24       | 2013-01-24      | 2013-01-24    
  2013-01-31      | 2013-01-31       | 2013-01-31      | 2012-11-30    
  2013-02-01      | 2013-02-01       | 2013-02-01      | 2013-02-01    
  2013-03-08      | 2013-03-08       | 2013-03-08      | 2013-03-08    
  ----NULL----    | ----NULL----     | 2013-02-28      | 2012-11-02    
  ----NULL----    | ----NULL----     | ----NULL----    | 2013-02-28
  </code></pre>
  
  <p>And when I display in the view it will be as follows</p>
  
  <pre><code>1. Sale date = 2013-01-24
  2. Sale date = 2013-01-31
  3. Sale date = 2013-02-01
  4. Sale date = 2013-03-08
  5. Sale date = 2013-02-28
  6. Sale date = 2013-02-28
  </code></pre>
  
  <p>But what I need is</p>
  
  <pre><code>1. Sale date = 2013-01-24
  2. Sale date = 2013-01-31
  3. Sale date = 2013-02-01
  4. Sale date = 2013-02-28
  5. Sale date = 2013-02-28
  6. Sale date = 2013-03-08
  </code></pre>
  
  <p>How can I accomplish this?</p>