Answers.Body: <p>The <a href="http://buildwithcraft.com/docs/relations#the-relatedTo-param"><code>relatedTo</code></a> param will do the trick:</p>
  
  <pre><code>{% set entries = craft.entries.limit(null) %}
  {% for category in craft.categories.relatedTo(entries).order('title asc') %}
      {% set entryCount = entries.relatedTo(category).total() %}
      {{ category }} ({{ entryCount }})
  {% endfor %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-22T18:13:45.153Z
Answers.Text: I think you want to change 'tag' to 'category' in your example. Otherwise your answer should be correct.
Answers.UserDisplayName: Bryan Redeagle
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-22T19:07:27.537Z
Answers.Text: Wow, how'd I forget to change that? Fixed, thanks.
Answers.UserDisplayName: Simon Kuran
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-22T07:49:47.320Z
Answers.LastActivityDate: 2014-06-22T19:12:06.483Z
Answers.LastEditDate: 2014-06-22T19:12:06.483Z
Answers.UserDisplayName: Simon Kuran
Body: <p>How do I list all categories in use alphabetically? And how to get the total post count from each category? </p>
  
  <p>Cheers﻿</p>
  
Tags: <entries><categories>
Title: Listing categories alphabetically & total post count
ThreadText: # Listing categories alphabetically & total post count
  
  (Asked by: username_0 on 2014-06-22)
  
  How do I list all categories in use alphabetically? And how to get the total post count from each category?
  
  Cheers﻿
  
  **Tags:** entries, categories
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2014-06-22. Score: 9
  
  The [`relatedTo`](http://buildwithcraft.com/docs/relations#the-relatedTo-param) param will do the trick:
  
  ```
  {% set entries = craft.entries.limit(null) %}
  {% for category in craft.categories.relatedTo(entries).order('title asc') %}
      {% set entryCount = entries.relatedTo(category).total() %}
      {{ category }} ({{ entryCount }})
  {% endfor %}
  
  ```
  
  > **Comments:**
  > **username_2**: I think you want to change 'tag' to 'category' in your example. Otherwise your answer should be correct.  
  > **username_1**: Wow, how'd I forget to change that? Fixed, thanks.  
  
  ---
  
  