Answers.Body: <p>Try using the <a href="https://craftcms.com/docs/templating/filters#group" rel="nofollow noreferrer">group filter</a></p>
  
  <pre><code>{% set entries = craft.entries.search(query).order('score') %}
  
  {% for sectionName, sectionEntries in entries | group('section.name') %}
      &lt;h2&gt;{{ sectionName }}&lt;/h2&gt;
  
      &lt;ul&gt;
          {% for entry in sectionEntries %}
              &lt;li&gt;{{ entry.title }}&lt;/li&gt;
          {% endfor %}
      &lt;/ul&gt;
  {% endfor %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-10-25T20:48:20.977Z
Answers.LastActivityDate: 2017-10-25T20:48:20.977Z
Answers.UserDisplayName: Trevor Davis
Body: <p>I have a set of entries from multiple channels and I want to loop through each section type that is in the set.</p>
  
  <p>Something like </p>
  
  <pre><code>{% set entries = craft.entries.search(query).order('score') %}
  
  {% for entrySection in entries.sections %}
      {{ entrySection.name }}
  {% endfor %}
  </code></pre>
  
  <p>So basically if I have 100 results from across 8 sections, is there a way I can list out those 8 sections separately?</p>
  
Tags: <entries><sections>
Title: In a large set of entries across multiple sections, how can I loop through each section type in the set?
ThreadText: # In a large set of entries across multiple sections, how can I loop through each section type in the set?
  
  (Asked by: username_0 on 2017-10-25)
  
  I have a set of entries from multiple channels and I want to loop through each section type that is in the set.
  
  Something like
  
  ```
  {% set entries = craft.entries.search(query).order('score') %}
  
  {% for entrySection in entries.sections %}
      {{ entrySection.name }}
  {% endfor %}
  
  ```
  
  So basically if I have 100 results from across 8 sections, is there a way I can list out those 8 sections separately?
  
  **Tags:** entries, sections
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2017-10-25. Score: 2 | Accepted answer
  
  Try using the [group filter](https://craftcms.com/docs/templating/filters#group)
  
  ```
  {% set entries = craft.entries.search(query).order('score') %}
  
  {% for sectionName, sectionEntries in entries | group('section.name') %}
      <h2>{{ sectionName }}</h2>
  
      <ul>
          {% for entry in sectionEntries %}
              <li>{{ entry.title }}</li>
          {% endfor %}
      </ul>
  {% endfor %}
  
  ```
  
  
  ---
  
  