title: Sort array on string and boolean in javascript
body: <p>I am having difficulty getting this sort to work.
  Current always has precedence over name.
  I can get it to sort on the values of either current or name but not both.</p>
  
  <p>My array look like this.</p>
  
  <pre><code>var arr = [{current:true, name:"A name"},
             {name:"A name"}, {name:"B name"},
             {current:true, name:"B name"}];
  arr.sort(sort_me)
  </code></pre>
  
  <p>Here's the sort function.</p>
  
  <pre><code>var sort_me = function(left, right){
                  var value = "name";
                  var sort_by_val = function(){
                      return left[value] == right[value] ? 0 : (left[value] &lt; right[value] ? -1 : 1);
                  }
                  if(left.current===right.current) {
                      sort_by_val();
                  }else{
                      if(left.current===true){
                          return -1;
                      }else{
                          if(right.current===true){
                              return 1;
                          }else{
                          sort_by_val();
                          }
                      }
                  }
              }
  </code></pre>