Creating a sitemap/index page, ordered by A-Z and 0-9 I'm created an Index like page (like at the back of a book) for entries within a certain section, ordered alphabetically with the letter proceeding it.

My code below seems like a tedious way to do it, is their an easier way? 

How would I handle the entries with a number as the first character (0-9) of the title?

     &lt;h2&gt;A&lt;/h2&gt;

     &lt;ul class="sub-nav"&gt;
      {% for entry in craft.entries.section('artists').search('title::A*').order('title').find() %}
        &lt;li&gt;...&lt;/li&gt;
        {% endfor %}
      &lt;/ul&gt;

    &lt;h2&gt;B&lt;/h2&gt;

     &lt;ul class="sub-nav"&gt;
      {% for entry in craft.entries.section('artists').search('title::B*').order('title').find() %}
        &lt;li&gt;...&lt;/li&gt;
        {% endfor %}
      &lt;/ul&gt;


    &lt;h2&gt;C&lt;/h2&gt;

     &lt;ul class="sub-nav"&gt;
      {% for entry in craft.entries.section('artists').search('title::C*').order('title').find() %}
        &lt;li&gt;...&lt;/li&gt;
        {% endfor %}
      &lt;/ul&gt;
The way to do this is with the group filter. You want to group the entries by the first character of the title.

Get the entries as an actual array

{% set allEntries = craft.entries.section('artists').order('title').find %}


Group them by first letter of title. first will return the first character of a string. upper converts a string to uppercase.

{% set groupedEntries = allEntries|group('title|first|upper') %}


Now you can loop through them:

{% for index, values in groupedEntries %}
  &lt;h2&gt;{{index}}&lt;/h2&gt;
  &lt;ul class="sub-nav"&gt;
    {% for e in values %}
      &lt;li&gt;...{{e}}...&lt;/li&gt;
    {% endfor %}
  &lt;/ul&gt;
{% endfor %}


See also this question.