{% extends 'AppBundle:Default:base.html.twig' %}
{% block body %}
    <h1>{{ 'Organizations' | trans }}</h1>
    <div class="row">
        <div class="col-sm-12">
        {% if organizations is not empty %}
        {% set last_initial = '' %}
        {% for organization in organizations %}
            {% set name = organization.nameLocalized(app.request.locale) %}
            {% set initial = name|first|upper %}
            {% if initial != last_initial %}
                {% if last_initial != '' %}
            </ul>
                {% endif %}
            <h2>{{ initial }}</h2>
            {% set last_initial = initial %}
            <ul class="list-unstyled">
            {% endif %}
            <li>
                <a href="{% if organization.gnd is not empty %}{{ path('organization-by-gnd', { 'gnd' : organization.gnd }) }}{% else %}{{ path('organization', { 'id' : organization.id }) }}{% endif %}">
                {{ name }}
                </a>
            </li>
        {% endfor %}
        </ul>
        {% else %}
            Es wurden keine Organisationen gefunden
        {% endif %}
        </div>
    </div><!-- .row -->
{% endblock %}

{% extends 'AppBundle:Default:base.html.twig' %}
{% block body %}
    <h1>{{ 'Organizations' | trans }}</h1>
    <div class="row">
        <div class="col-sm-12">
        {% if organizations is not empty %}
        {% set last_initial = '' %}
        {% for organization in organizations %}
            {% set name = organization.nameLocalized(app.request.locale) %}
            {# TODO: sort in solr and move to name|first|upper #}
            {% set initial = slugify.slugify(organization.name)|first|upper %}
            {% if initial != last_initial %}
                {% if last_initial != '' %}
            </ul>
                {% endif %}
            <h2>{{ initial }}</h2>
            {% set last_initial = initial %}
            <ul class="list-unstyled">
            {% endif %}
            <li>
                <a href="{% if organization.gnd is not empty %}{{ path('organization-by-gnd', { 'gnd' : organization.gnd }) }}{% else %}{{ path('organization', { 'id' : organization.id }) }}{% endif %}">
                {{ name }}
                </a>
            </li>
        {% endfor %}
        </ul>
        {% else %}
            Es wurden keine Organisationen gefunden
        {% endif %}
        </div>
    </div><!-- .row -->
{% endblock %}

Adjust initial as long as we don't localize sort
Adjust initial as long as we don't localize sort
