title: Sort after Map/Reduce with inline result
body: <p>After trying this <a href="https://stackoverflow.com/questions/9643876/map-reduce-and-sort-nested-document">solution</a> and getting one step further i have another question regarding mongodb.</p>
  
  <p>My question is:</p>
  
  <p>How can i sort the output of:</p>
  
  <pre><code>doc = {_id : 16, days : { 1 : 123, 2 : 129, 3 : 140, 4 : 56, 5 : 57, 6 : 69, 7 : 80 }};
  db.so.insert(doc);
  
  map = function() {
    emit(this._id, this.days["1"]);
    emit(this._id, this.days["3"]); 
    emit(this._id, this.days["7"]); 
  }
  
  reduce = function (k, vals) {
    var sum = 0;
    vals.forEach(function (v) {sum += v;});
    return sum;
  }
  
  res = db.so.mapReduce(map, reduce, {out : {inline : 1}});
  res.find();
  </code></pre>
  
  <p>The Output is like this:</p>
  
  <pre><code>"results" : [
      {
              "_id" : 16,
              "value" : 225
      },
      {
              "_id" : 33,
              "value" : 230
      },
      {
              "_id" : 302,
              "value" : 274
      }
  </code></pre>
  
  <p>]</p>
  
  <p>Now i want to sort the result with:</p>
  
  <pre><code>res.find().sort({ "results.value":-1 });
  </code></pre>
  
  <p>which results in this error:</p>
  
  <pre><code>Sat Mar 31 01:15:45 TypeError: res.find().sort({'results.value':-1}) is not a function (shell):1
  </code></pre>
  
  <p>Does anybody can help me ?</p>