Loop through all entry types, separate each group type by line rule (hr) I'm looking for shorter way of doing this:

dog dog dog

––––––––––––––––––––––––––

cat cat cat

––––––––––––––––––––––––––

hamster hamster hamster

Currently, I have to run 3 independent loops to group pet types together, and insert a line rule between them.

How can I group pet types together and separate using a line rule?

&lt;div class="row"&gt;
      {% for pet in entries %}
            {% if pet.kind == 'dog' %}
                {% include '_partials/animalOrgChart' with {
                  title: pet.title,
                  subTitle: pet.jobTitle,
                  img: pet.headshot|length ? pet.headshot[0],                      
                  url: pet.url,
                  portrait: true
                } %}
            {% endif %}
      {% endfor %}
    &lt;hr class="line" /&gt; 
  &lt;/div&gt;
&lt;div class="row"&gt;
          {% for pet in entries %}
                {% if pet.kind == 'cat' %}
                    {% include '_partials/animalOrgChart' with {
                      title: pet.title,
                      subTitle: pet.jobTitle,
                      img: pet.headshot|length ? pet.headshot[0],                      
                      url: pet.url,
                      portrait: true
                    } %}
                {% endif %}
          {% endfor %}
        &lt;hr class="line" /&gt; 
   &lt;/div&gt;
&lt;div class="row"&gt;
          {% for pet in entries %}
                {% if pet.kind == 'hamster' %}
                    {% include '_partials/animalOrgChart' with {
                      title: pet.title,
                      subTitle: pet.jobTitle,
                      img: pet.headshot|length ? pet.headshot[0],                      
                      url: pet.url,
                      portrait: true
                    } %}
                {% endif %}
          {% endfor %}
        &lt;hr class="line" /&gt; 
   &lt;/div&gt;
You can use the group filter

{% set allEntries = craft.entries.section('pets').all() %}
{% set allEntriesByType = allEntries|group('type') %}
{% for type, pets in allEntriesByType %}

     All Pets of Type {{ type }}

     {% for pet in pets %}
         {% include '_partials/animalOrgChart' with {
             title: pet.title,
             subTitle: pet.jobTitle,
             img: pet.headshot|length ? pet.headshot[0],                      
             url: pet.url,
             portrait: true
         } %}        
    {% endfor %}

    &lt;hr class="line" /&gt; 
{% endfor %}