Group entries by section How do I group entries by section? I have search results:

{% set entries = allowedSearchableEntries.search(query).order('score').limit(100) %}


But I want to have

SECTION NAME
entry 1
entry 4
entry 6

SECTION NAME
entry 3
entry 12

etc.
You can use the Twig group filter.

{% set entries = allowedSearchableEntries.search(query).order('score').limit(100) %}

{% set entriesBySection = entries|group('section') %}

{% for section, entriesInSection in entriesBySection %}
    &lt;h2&gt;{{ section }}&lt;/h2&gt;

    &lt;ul&gt;
        {% for entry in entriesInSection %}
            &lt;li&gt;&lt;a href="{{ entry.url }}"&gt;{{ entry.title }}&lt;/a&gt;&lt;/li&gt;
        {% endfor %}
    &lt;/ul&gt;
{% endfor %}