Answers.Body: <p>Using the <code>group</code> filter you will always end up with the sort order of your entries. So you would need to sort the entries by your categories field, but this probably doesn't work.</p>
  
  <p>But you can do the following:</p>
  
  <pre><code>{# Get the categories related to my "entrySection" entries in custom order #}
  {% set entries = craft.entries.section('entrySection') %}
  {% set relatedCats = craft.categories.relatedTo(entries).order('customCatField desc') %}
  
  {# Loop the categories #}
  {% for category in relatedCats %}
  
      {# Get and loop through the 6 most recent entries related to this cat #}
      {% set relatedEntries = craft.entries.relatedTo(category).limit('6') %}
      {% for entry in relatedEntries %}
          ...
      {% endfor %}
  
  {% endfor %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-12-04T17:52:16.190Z
Answers.Text: For whatever reason, putting a category field into the order function threw errors, but I was able to get it working by using dateUpdated instead. Otherwise this worked perfectly!
Answers.UserDisplayName: brandongcarroll
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-12-04T18:34:33.937Z
Answers.Text: With "customCatField" I actually meant a custom field assigned to your categories (e.g. category color)! Glad it worked for you :)
Answers.UserDisplayName: carlcs
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-12-08T14:03:24.807Z
Answers.Text: Thank you @carlcs I had looked at that too, but yes that does exactly what I need after actually implementing it :)
Answers.UserDisplayName: Gareth
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-12-04T16:13:04.677Z
Answers.LastActivityDate: 2014-12-04T16:13:04.677Z
Answers.UserDisplayName: carlcs
Body: <p>This is what I'm trying to accomplish:</p>
  
  <ul>
  <li>All categories displayed on one page, with entries returned from each.</li>
  <li>Only six entries shown in each category.</li>
  <li>Categories need to be in a specific order.</li>
  </ul>
  
  <p>I've got the first two points working, but can't figure out how to change the order of the categories. Am I going about this the wrong way?</p>
  
  <pre><code>{% set entries = craft.entries.section('entrySection').find() %}
  
  {% for category, catEntries in entries | group('categoryField.first().title') %}
  
      {% for entry in catEntries|slice(0,6) %}
  
      {% endfor %}
  
  {% endfor %}
  </code></pre>
  
Tags: <categories><forloop><order>
Title: How to order categories in key/value for loop?
ThreadText: # How to order categories in key/value for loop?
  
  (Asked by: username_0 on 2014-12-04)
  
  This is what I'm trying to accomplish:
  
  * All categories displayed on one page, with entries returned from each.
  * Only six entries shown in each category.
  * Categories need to be in a specific order.
  
  I've got the first two points working, but can't figure out how to change the order of the categories. Am I going about this the wrong way?
  
  ```
  {% set entries = craft.entries.section('entrySection').find() %}
  
  {% for category, catEntries in entries | group('categoryField.first().title') %}
  
      {% for entry in catEntries|slice(0,6) %}
  
      {% endfor %}
  
  {% endfor %}
  
  ```
  
  **Tags:** categories, forloop, order
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2014-12-04. Score: 2
  
  Using the `group` filter you will always end up with the sort order of your entries. So you would need to sort the entries by your categories field, but this probably doesn't work.
  
  But you can do the following:
  
  ```
  {# Get the categories related to my "entrySection" entries in custom order #}
  {% set entries = craft.entries.section('entrySection') %}
  {% set relatedCats = craft.categories.relatedTo(entries).order('customCatField desc') %}
  
  {# Loop the categories #}
  {% for category in relatedCats %}
  
      {# Get and loop through the 6 most recent entries related to this cat #}
      {% set relatedEntries = craft.entries.relatedTo(category).limit('6') %}
      {% for entry in relatedEntries %}
          ...
      {% endfor %}
  
  {% endfor %}
  
  ```
  
  > **Comments:**
  > **username_0**: For whatever reason, putting a category field into the order function threw errors, but I was able to get it working by using dateUpdated instead. Otherwise this worked perfectly!  
  > **username_1**: With "customCatField" I actually meant a custom field assigned to your categories (e.g. category color)! Glad it worked for you :)  
  > **username_2**: Thank you @username_1 I had looked at that too, but yes that does exactly what I need after actually implementing it :)  
  
  ---
  
  