Ordering Structure Sections with Structure Handles I am using the code below to output a group of sections that have entries along with their section handle. How would I order the sections (ideally by structureId)? I'm not opposed to using supersort but I haven't been able to achieve the desired result.

{% set sections = craft.sections.getAllSections() %}
{% set entries = craft.entries.section(['first', 'second', 'third']) %}
{% set grouped = entries|group('section') %}

{% for sectionHandle, sectionEntries in grouped %}
    {% set groupSection = false %}
    {% for section in sections %}
        {% if section.name == sectionHandle %}
            {% set groupSection = section %}
        {% endif %}
    {% endfor %}

    {% if groupSection %}
        &lt;h1&gt;{{ groupSection.name }} - {{ groupSection.handle }}&lt;/h1&gt;
    {% endif %}
{% endfor %}
Use SuperSort or write your own Twig filter for it. Craft/Twig don't come with a sort filter to sort by key and replicating the functionality  (storing array keys, nested loops) is possible but kind of messy and also not performing as well.

I can understand the desire to not be reliant on too many plugin, but the functionality you need from SuperSort is simply a wrapper for a PHP function, so you can easily swap it out for another plugin if ever necessary.

It is also a great opportunity to start looking into plugin dev, write your first Twig extension or a simple Template Variable might just do it.