title: Sorting (alphabetical order) to ignore empty cells : dataTables
body: <p>So the question has already been asked <a href="http://datatables.net/forums/discussion/4025/sorting-to-ignore-empty-cells" rel="noreferrer">here</a>, but the solution doesn't work for me (I might do something wrong). I want to sort my tables by alphabetical order ("type" : "natural"), but I want the empty cells to be at the bottom (for desc and asc).</p>
  
  <p>I tried the previous solution given by fbas :</p>
  
  <pre><code>jQuery.fn.dataTableExt.oSort['mystring-asc'] = function(x,y) {
      var retVal;
      x = $.trim(x);
      y = $.trim(y);
  
      if (x==y) retVal= 0;
      else if (x == "" || x == "&amp;nbsp;") retVal=  1;
      else if (y == "" || y == "&amp;nbsp;") retVal=  -1;
      else if (x &gt; y) retVal=  1;
      else retVal = -1;  // &lt;- this was missing in version 1
  
      return retVal;
  }
  jQuery.fn.dataTableExt.oSort['mystring-desc'] = function(y,x) {
      var retVal;
      x = $.trim(x);
      y = $.trim(y);
  
      if (x==y) retVal= 0; 
      else if (x == "" || x == "&amp;nbsp;") retVal=  -1;
      else if (y == "" || y == "&amp;nbsp;") retVal=  1;
      else if (x &gt; y) retVal=  1;
      else retVal = -1; // &lt;- this was missing in version 1
  
      return retVal;
   }
  </code></pre>
  
  <p>With :</p>
  
  <pre><code>$(document).ready(function() {
      $('#classement').dataTable({
      "aoColumns": [
          null,
          null,
          { "type" : "mystring" },
          { "type" : "mystring" },
          null
      ]
      } );
  } );
  </code></pre>
  
  <p>With a table like <code>| N° | Edit | Song | Singer | Url |</code>
  Sorting only on Song and Singer.</p>
  
  <p>The emty cells are at the bottom (as expected) but now the sorting has no logic (no alphabetical order, should I use another property in dataTable?).</p>
  
  <p>Does anyone have a solution?</p>
  
  <p><strong>Edit :</strong> If we add a line dynamically, how to refresh the sorting ?</p>
  
  <pre><code>$("#example").find('tbody')
      .append($('&lt;tr&gt;')
          .append($('&lt;td&gt;')
                  .text('Boro')
              )     
      );
  </code></pre>
  
  <p><a href="http://jsfiddle.net/Fanch/cbL9r757/" rel="noreferrer">JsFiddle (use isim's one) </a></p>