title: MongoDB nested object aggregation sum and sort
body: <p>I have highly nested mongodb set of objects and i want to sort subofdocuments according to the result of sum their votes for example :</p>
  
  <pre><code>{
     "_id":17846384es,
     "company_name":"company1",
     "products":[
         {
           "product_id":"123785",
           "product_name":"product1",
           "user_votes":[
                {
                   "user_id":1,
                    "vote":1
                },
                {
                   "user_id":2,
                    "vote":2
                }
            ]
         },
         {
           "product_id":"98765",
           "product_name":"product2",
           "user_votes":[
                {
                   "user_id":5,
                    "vote":3
                },
                {
                   "user_id":3,
                    "vote":3
                }
            ]
         }
      ]
  }  
  </code></pre>
  
  <p>i want to sort as descending products according to the result of sum their votes
  the expected output is </p>
  
  <pre><code>{
     "_id":17846384es,
     "company_name":"company1",
     "products":[
         {
           "product_id":"98765",
           "product_name":"product2",
           "user_votes":[
                {
                   "user_id":5,
                    "vote":3
                },
                {
                   "user_id":3,
                    "vote":3
                }
            ]
          "votes":8
         },
         {
           "product_id":"123785",
           "product_name":"product1",
           "user_votes":[
                {
                   "user_id":1,
                    "vote":1
                },
                {
                   "user_id":2,
                    "vote":2
                }
            ],
            "votes":3
         }
      ]
  }  
  </code></pre>
  
  <p>Any Idea ? </p>