title: Array sorting with condition in Javascript
body: <p>I need to sort an array in ascending order and to put all zeros in the end.</p>
  
  <p>For example [0, 0, 0, 3, 2, 1] needs to be sorted to [1, 2, 3, 0, 0, 0].
  This is my code, what do I need to add to make sure all zeros are at the end?</p>
  
  <pre><code>function sort_by_field(array, field){
                  return array.sort(function(a, b){
                      if( a[field] &gt; b[field] ){
                          return 1;
                      }
                      if( a[field] &lt; b[field] ){
                          return -1;
                      }
                      return 0;
                  });
              }
  </code></pre>
  
  <p>Any help will be appreciated. </p>