Answers.Body: <p>To group by the first letter you would simply use the <a href="http://twig.sensiolabs.org/doc/filters/slice.html" rel="nofollow"><code>slice</code></a> filter within Craft's <a href="http://buildwithcraft.com/docs/templating/filters#group" rel="nofollow"><code>group</code></a>
  filter.</p>
  
  <p>For all non letter characters you can now use Craft's <a href="http://buildwithcraft.com/docs/templating/filters#replace" rel="nofollow"><code>replace</code></a> filter (it does regex since Craft 2.2)
  and replace them with whatever you want these entries to be sorted by.</p>
  
  <pre><code>{% set entriesGrouped = entries|group('title|slice(0, 1)|upper|replace("/[^A-Z]/", "0-9")') %}
  
  {% for letter, entriesInGroup in entriesGrouped %}
      {{ letter }}
      {% for entry in entriesInGroup %}
          {{ entry.title }}
      {% endfor %}
  {% endfor %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-03-20T15:26:38.493Z
Answers.Text: OK, that's MUCH nicer ;). Wasn't aware of the fact that slice can be used within group ...
Answers.UserDisplayName: Paul
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-03-20T15:29:50.947Z
Answers.Text: I found out some days ago, that you can even go crazy and do things like ternary in there: [Sorting entries A-Z, ignoring 'The' and grouping by first letter](http://craftcms.stackexchange.com/a/8665/125)
Answers.UserDisplayName: carlcs
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-03-20T15:34:23.083Z
Answers.Text: Nice. Very elegant!
Answers.UserDisplayName: Michael Rog
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-03-20T15:40:23.003Z
Answers.Text: Better to add | upper
  
  {% set entriesGrouped = entries|group('title|slice(0, 1)|replace("/[^a-zA-Z]/", "0-9") | upper') %}
Answers.UserDisplayName: Johannes Lamers
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-03-20T15:21:27.227Z
Answers.LastActivityDate: 2015-03-20T15:43:45.650Z
Answers.LastEditDate: 2015-03-20T15:43:45.650Z
Answers.UserDisplayName: carlcs
Body: <p>I'm trying to output a list of Brand names grouped by first letter. But some items have a number or symbol in the name. I want to list first the Numbers and symbols under 0-9 and the rest of the brands under A-Z</p>
  
  <p>Like this:</p>
  
  <p><strong>0-9</strong></p>
  
  <ul>
  <li>+People</li>
  <li>10 Days</li>
  <li>2Two</li>
  <li>40 Weft</li>
  <li>55 DSL</li>
  <li>81hours</li>
  </ul>
  
  <p><strong>A</strong></p>
  
  <ul>
  <li>Acne</li>
  <li>Adidas</li>
  </ul>
  
  <p><strong>B</strong></p>
  
  <ul>
  <li>B.Young</li>
  <li>etc etc.</li>
  </ul>
  
Tags: <templating><categories><array><group>
Title: List Categories by 0-9 and A-Z
ThreadText: # List Categories by 0-9 and A-Z
  
  (Asked by: username_0 on 2015-03-20)
  
  I'm trying to output a list of Brand names grouped by first letter. But some items have a number or symbol in the name. I want to list first the Numbers and symbols under 0-9 and the rest of the brands under A-Z
  
  Like this:
  
  **0-9**
  
  * +People
  * 10 Days
  * 2Two
  * 40 Weft
  * 55 DSL
  * 81hours
  
  **A**
  
  * Acne
  * Adidas
  
  **B**
  
  * B.Young
  * etc etc.
  
  **Tags:** templating, categories, array, group
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2015-03-20. Score: 5 | Accepted answer
  
  To group by the first letter you would simply use the [`slice`](http://twig.sensiolabs.org/doc/filters/slice.html) filter within Craft's [`group`](http://buildwithcraft.com/docs/templating/filters#group)
  filter.
  
  For all non letter characters you can now use Craft's [`replace`](http://buildwithcraft.com/docs/templating/filters#replace) filter (it does regex since Craft 2.2)
  and replace them with whatever you want these entries to be sorted by.
  
  ```
  {% set entriesGrouped = entries|group('title|slice(0, 1)|upper|replace("/[^A-Z]/", "0-9")') %}
  
  {% for letter, entriesInGroup in entriesGrouped %}
      {{ letter }}
      {% for entry in entriesInGroup %}
          {{ entry.title }}
      {% endfor %}
  {% endfor %}
  
  ```
  
  > **Comments:**
  > **username_2**: OK, that's MUCH nicer ;). Wasn't aware of the fact that slice can be used within group ...  
  > **username_1**: I found out some days ago, that you can even go crazy and do things like ternary in there: [Sorting entries A-Z, ignoring 'The' and grouping by first letter](http://craftcms.stackexchange.com/a/8665/125)  
  > **username_3**: Nice. Very elegant!  
  > **username_0**: Better to add | upper  {% set entriesGrouped = entries|group('title|slice(0, 1)|replace("/[^a-zA-Z]/", "0-9") | upper') %}  
  
  ---
  
  