title: Sort javascript array so that blank values are always at bottom
body: <p>So I have an array of arrays which contain only strings. 
  The array of arrays is to be displayed as a table and may have over 1000 rows with 20 or more values in each.</p>
  
  <p>eg:</p>
  
  <pre><code>var arr = [
      ["bob","12","yes"],
      ["joe","","no"],
      ["tim","19","no"],
      ["dan","","yes"],
      ["tim","",""],
      ["dan","0",""]
  ]
  </code></pre>
  
  <p>the strings may contain anything that can be represented as a string, including: <code>" "</code>, <code>""</code>, <code>"0"</code> or <code>"00-00-00"</code> etc... and any column my be used for ordering.</p>
  
  <p>I am sorting the arrays ascending and descending but some of the values I am sorting by are blank strings: <code>""</code>. How could I get the blank strings (only) to always be at the end of the new arrays in all modern browsers?</p>
  
  <p>currently they are at the end when ascending but at the start when descending.</p>
  
  <p>I am sorting like below (Yes I'm sure I can do it shorter too):</p>
  
  <pre><code>if (direction == "asc") {
      SortedArr = arr.sort(function (a, b) {
          if (a[colToSortBy] == '') {
              return -1;
          }
          if (a[colToSortBy].toUpperCase() &lt; b[colToSortBy].toUpperCase()) {
              return -1;
          }
          if (a[colToSortBy].toUpperCase() &gt; b[colToSortBy].toUpperCase()) {
              return 1;
          }
          return 0;
      });
  } else {
      SortedArr = arr.sort(function (a, b) {
          if (a[colToSortBy] == '') {
              return -1;
          }
          if (b[colToSortBy].toUpperCase() &lt; a[colToSortBy].toUpperCase()) {
              return -1;
          }
          if (b[colToSortBy].toUpperCase() &gt; a[colToSortBy].toUpperCase()) {
              return 1;
          }
          return 0;
      });
  }
  </code></pre>