docs: def do_groupby(environment, value, attribute):
      """Group a sequence of objects by a common attribute.
  
      If you for example have a list of dicts or objects that represent persons
      with `gender`, `first_name` and `last_name` attributes and you want to
      group all users by genders you can do something like the following
      snippet:
  
      .. sourcecode:: html+jinja
  
          <ul>
          {% for group in persons|groupby('gender') %}
              <li>{{ group.grouper }}<ul>
              {% for person in group.list %}
                  <li>{{ person.first_name }} {{ person.last_name }}</li>
              {% endfor %}</ul></li>
          {% endfor %}
          </ul>
  
      Additionally it's possible to use tuple unpacking for the grouper and
      list:
  
      .. sourcecode:: html+jinja
  
          <ul>
          {% for grouper, list in persons|groupby('gender') %}
              ...
          {% endfor %}
          </ul>
  
      As you can see the item we're grouping by is stored in the `grouper`
      attribute and the `list` contains all the objects that have this grouper
      in common.
      """
      expr = lambda x: environment.getitem(x, attribute)
      return sorted(map(_GroupTuple, groupby(sorted(value, key=expr), expr)))