Order grouped entries I need to group and order member profiles alphabetically but I can't get it to work. Have a look here: http://ffsd.de.w0129b45.kasserver.com/mitglieder
(It's german but you should get the idea :))

In everything I tried either the groups are ordered correctly or the contents (profiles) of the group are… but never both. Here's the relevant code:

{% set allProfiles = craft.entries.section('members').order('profileLastname').limit(null) %}
{% for letter, profiles in allProfiles|group("profileAlphabet") %}
    &lt;ul class="member__index"&gt;
        &lt;li class="item letter"&gt;
            &lt;span id="{{ letter }}"&gt;
                &lt;div class="avatar"&gt;
                    &lt;span class="initials letter"&gt;{{ letter }}&lt;/span&gt;
                &lt;/div&gt;
            &lt;/span&gt;
        &lt;/li&gt;

        {% for profile in profiles %}
            &lt;li class="item"&gt;
                &lt;a href="{{ profile.url }}"&gt;&lt;h3&gt;{{ profile.title }}&lt;/h3&gt;&lt;/a&gt;
            &lt;/li&gt;
        {% endfor %}
    &lt;/ul&gt;
{% endfor %}


As you can see, I'd like to order the profiles by the custom field "profileLastname" and the groups by "profileAlphabet".

Any ideas?
The probably most easy way to do this is to sort the grouped array by key, which unfortunatelly is only possible with
a plugin, as Twig's sort filter only allows to sort by value.

Here I'm using Michael Rog's Supersort, but there are also other plugins that do this.

{% set allProfiles = craft.entries.section('members').order('profileLastname').limit(null) %}
{% set allProfilesGrouped = allProfiles|group("profileAlphabet")|supersort('ksort') %}