title: Mongodb aggregate $sort by $match
body: <p>I have a user collection with sub document of 'music' that has a sub document of 'likes'. I'll like to run a search and find the top 10 users who liked a specific artist the most, sorted by how much they liked them. this is how the dataset is structured</p>
  
  <pre><code>[
  {
      '_id' : ObjectId("507f1f77bcf86cd799439011"),
      'user_name' : "John",
      'music' : [
          'likes' [
              {'name': 'david bowie', 'strength': 50 },
              {'name': 'john lennon', 'strength': 100 },
              {'name': 'bob marley', 'strength': 20 },
          ]
      ]
  },
  {
      '_id' : ObjectId("54304264e77cc5a1670cb318"),
      'user_name' : "Paul",
      'music' : [
          'likes' [
              {'name': 'david bowie', 'strength': 60 },
              {'name': 'john lennon', 'strength': 70 },
              {'name': 'bob marley', 'strength': 100 },
          ]
      ]
  }
  ]
  </code></pre>
  
  <p>I've been trying to use the following aggregate command:</p>
  
  <pre><code>$artist = "david bowie";
  $db-&gt;collection-&gt;aggregate( 
          array( 
              array( '$project' =&gt; array( 'Likes' =&gt; '$music.likes' ) ),
              array( '$match' =&gt; array( 'Likes.name' =&gt; $artist ) ),
              array( '$sort' =&gt; array( 'Likes.strength' =&gt; 1 ) ),
              array( '$limit' =&gt; 10 )
              )
          );
  </code></pre>
  
  <p>the match does works, but it only sort the Likes not the overall results.
  also - is there a way not to return all the items in the Likes document but just the one that is related to the match?</p>
  
  <p>here is the results I'm getting</p>
  
  <pre><code>[
  { 
      ["_id"]=&gt; object(MongoId)#310 (1) { ["$id"]=&gt; string(24) "507f1f77bcf86cd799439011",
      ["Likes"] =&gt; array(49) { 
          [0]=&gt; array(2) { ["name"]=&gt; string(11) "john lennon" ["strength"]=&gt; float(100) },
          [1]=&gt; array(2) { ["name"]=&gt; string(11) "david bowie" ["strength"]=&gt; float(50) },
          [2]=&gt; array(2) { ["name"]=&gt; string(11) "bob marley" ["strength"]=&gt; float(20) },
          ...
      }
  },
  { 
      ["_id"]=&gt; object(MongoId)#310 (1) { ["$id"]=&gt; string(24) "54304264e77cc5a1670cb318",
      ["Likes"] =&gt; array(49) { 
          [0]=&gt; array(2) { ["name"]=&gt; string(11) "bob marley" ["strength"]=&gt; float(100) },
          [1]=&gt; array(2) { ["name"]=&gt; string(11) "john lennon" ["strength"]=&gt; float(70) },
          [2]=&gt; array(2) { ["name"]=&gt; string(11) "david bowie" ["strength"]=&gt; float(60) },
          ...
      }
  }   
  ]
  </code></pre>
  
  <p>should I be using a different combination of commands in the aggregate?</p>