Answers.Body: <p>Seems I needed to put in the order filter</p>
  
  <pre><code>{% set categories = craft.categories.group('programs').order('title') %}
  
  {% set categoriesGroup = categories|group('title|slice(0, 
  1)|replace("/[^a-zA-Z]/", "0-9") | upper') %} 
  &lt;ul&gt;
  {% for letter, categoriesInGroup in categoriesGroup %}
  {{ letter }}
  {% for category in categoriesInGroup %}
    &lt;li&gt;{{ category.title }}&lt;/li&gt;
  {% endfor %}
  
  {% endfor %}
  &lt;/ul&gt;
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-05-04T02:21:13.330Z
Answers.LastActivityDate: 2018-05-04T02:21:13.330Z
Answers.UserDisplayName: Vin
Body: <p>I have a list of categories that I am listing out, grouping by alphabet.  The issue is the list goes A H B C D E...and so on.  Why would it go in that order?</p>
  
  <pre><code>{% set categories = craft.categories.group('programs') %}
  
  {% set categoriesGroup = categories|group('title|slice(0, 
  1)|replace("/[^a-zA-Z]/", "0-9") | upper') %} 
  &lt;ul&gt;
  {% for letter, categoriesInGroup in categoriesGroup %}
  {{ letter }}
  {% for category in categoriesInGroup %}
    &lt;li&gt;{{ category.title }}&lt;/li&gt;
  {% endfor %}
  
  {% endfor %}
  &lt;/ul&gt;
  </code></pre>
  
Tags: <craft3><sorting>
Title: Group and Sort Alphabetically
ThreadText: # Group and Sort Alphabetically
  
  (Asked by: username_0 on 2018-05-04)
  
  I have a list of categories that I am listing out, grouping by alphabet. The issue is the list goes A H B C D E...and so on. Why would it go in that order?
  
  ```
  {% set categories = craft.categories.group('programs') %}
  
  {% set categoriesGroup = categories|group('title|slice(0, 
  1)|replace("/[^a-zA-Z]/", "0-9") | upper') %} 
  <ul>
  {% for letter, categoriesInGroup in categoriesGroup %}
  {{ letter }}
  {% for category in categoriesInGroup %}
    <li>{{ category.title }}</li>
  {% endfor %}
  
  {% endfor %}
  </ul>
  
  ```
  
  **Tags:** craft3, sorting
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2018-05-04. Score: 4
  
  Seems I needed to put in the order filter
  
  ```
  {% set categories = craft.categories.group('programs').order('title') %}
  
  {% set categoriesGroup = categories|group('title|slice(0, 
  1)|replace("/[^a-zA-Z]/", "0-9") | upper') %} 
  <ul>
  {% for letter, categoriesInGroup in categoriesGroup %}
  {{ letter }}
  {% for category in categoriesInGroup %}
    <li>{{ category.title }}</li>
  {% endfor %}
  
  {% endfor %}
  </ul>
  
  ```
  
  
  ---
  
  