title: Order list by queryset count in Django/Python
body: <p>Sorry this is basic, but I'm new to Python and Django.</p>
  
  <p>I have a list of users who have performed an action that is being saved in a separate table. I want to show a list of these users, sorted by how many times they've taken the other action.</p>
  
  <p>I understand how to get the counts:</p>
  
  <pre><code>users = User.objects.all()
  for user in users:
      print user.action_set.count()
  </code></pre>
  
  <p>And I understand how to show the counts in my template:</p>
  
  <pre><code>{% for user in users %}
      {{ user.action_set.count }}
  {% endfor %}
  </code></pre>
  
  <p>But I'm not sure how to have it sort the users by the count of the action set.</p>