title: Understanding simple sorting script , that compares values
body: <p>I was just searching for a simple jquery sorting script and found this online: </p>
  
  <pre><code>$(function() {
      $('ol').each(function() {
          var matches = $('li', this).filter(function() { // Each item
              var text = $(this).text();
              return $('ul.three li').filter(function() { // Are there matches in .three?
                  return $(this).text() == text;
              }).length &gt; 0;
          }).length;
          $('li:last', this).text((matches * 10) + ' Points');
      });
  });
  </code></pre>
  
  <p><strong><a href="http://jsfiddle.net/wemtzx76/5/" rel="nofollow">FIDDLE HERE</a></strong></p>
  
  <p>Notice how the values of the first 2 tables are compared with that of the values of the third table. now my question is about how <code>matches</code> is incremented, i went through the whole script, but don't quite understand how matches gets a value of 4 and 2 for the first and second table respectively(displayed in the respective table as 40 and 20). I understand the usage of the <code>filter</code> function, but don't quite understand how matches gets its value, I know the <code>length</code> property is involved, i see it at the end of the return statement, But still don't quite understand how is matches incremented ? </p>