title: Getting a Count of Array Items that Meet a Certain Criteria
body: <p>I have an array called @friend_comparisons which is populated with a number of user objects. I then sort the array using the following:</p>
  
  <pre><code>@friend_comparisons.sort! { |a,b| b.completions.where(:list_id =&gt; @list.id).first.counter &lt;=&gt; a.completions.where(:list_id =&gt; @list.id).first.counter }
  </code></pre>
  
  <p>This is sorting the array by a certain counter associated with each user (the specifics of which are not important to the question).</p>
  
  <p>I want to find out how many user objects in the array have a counter that is greater than a certain number (let's say 5). How do I do this?</p>
  
  <p>Here is how I am currently solving the problem:</p>
  
  <pre><code>@friends_rank = 1
  for friend in @friend_comparisons do
    if friend.completions.where(:list_id =&gt; @list.id).first.counter &gt; @user_restaurants.count
      @friends_rank = @friends_rank + 1
    end
  end
  </code></pre>