title: MongoDB v2.4.9 sort by boolean field
body: <p>How do I sort query results based on a boolean field?</p>
  
  <p>Consider the following collection:</p>
  
  <pre><code>{ "_id" : ObjectId("..."), "name" : "John" , "isFoo" : true}
  { "_id" : ObjectId("..."), "name" : "Jim" , "isFoo" : false}
  { "_id" : ObjectId("..."), "name" : "Joel" , "isFoo" : false}
  { "_id" : ObjectId("..."), "name" : "Jill" , "isFoo" : true}
  { "_id" : ObjectId("..."), "name" : "Samantha" , "isFoo" : true}
  </code></pre>
  
  <p>I need a query that will return the <code>isFoo == true</code> first and the <code>isFoo == false</code> documents second. In other words, I need to sort by a boolean field. </p>
  
  <p>The following code is does not do the trick as I still get some documents with <code>isFoo == true</code> mixed in with the false ones.</p>
  
  <pre><code>db["users"].find().sort( { isFoo: 1 } )
  </code></pre>
  
  <p>Ideas?</p>