Answers.Body: <p>I don't think you can order by the types order, or get the types in your template (I might be wrong there though), but maybe you don't need to let this be completely dynamic? I guess the user won't be able to add new types or change the order of them after the site is made? If so, couldn't you just make an array of the types and do somthing like this:</p>
  
  <pre><code>{% set typesInOrder = ['handle1', 'handle2', 'handle3'] %}
  
  {% for type in typesInOrder %}
      {% for entry in craft.entries.type(type) %}
           {{ entry.title }}
      {% endfor %}
  {% endfor %}
  </code></pre>
  
  <p>There is of course some limitations, especially if you need to paginate the results. And it's bad for performance to do the craft.entries queries several times, especially if you have many entrytypes. Just thought I'd share this in case it's helpful for your usecase.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-11-24T23:12:38.793Z
Answers.Text: André, recommend your Preparse plugin! A simple switch conditional `{% switch entry.type %}{% case 'handle1' %}1{% case 'handle2' %}2{% default %}99{% endswitch %}` and you can use `{% set entries = craft.entries.order('myPreparseHandle') %}`.
Answers.UserDisplayName: carlcs
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-11-24T23:43:08.687Z
Answers.Text: Yep, that works just fine. The order in this case won't change. Thanks for the idea!
Answers.UserDisplayName: cbad
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-11-24T22:42:46.000Z
Answers.LastActivityDate: 2015-11-24T22:42:46.000Z
Answers.UserDisplayName: André Elvan
Answers.Body: <p>You could try it with a MySQL <a href="https://dev.mysql.com/doc/refman/5.7/en/control-flow-functions.html#operator_case" rel="nofollow"><code>CASE</code></a> expression in the <code>order</code> parameter:</p>
  
  <pre><code>{% set orderParam = "CASE
      WHEN type = 'handle1' THEN 1
      WHEN type = 'handle2' THEN 2
      WHEN type = 'handle3' THEN 3
      ELSE 99
  END" %}
  
  {% set entries = craft.entries.section('blog').order(orderParam) %}
  </code></pre>
  
  <p>Another <em>untested</em> suggestion is to try and make this dynamic (order similar to CP):</p>
  
  <pre><code>{% set section = craft.sections.getSectionById(2) %}
  
  {% set orderParam = "CASE" %}
  
  {% for entryType in section.getEntryTypes() %}
      {% set orderParam = orderParam ~ " WHEN type = '" ~ entryType ~ "' THEN " ~ loop.index %}
  {% endfor %}
  
  {% set orderParam = orderParam ~ " ELSE 99 END" %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-11-24T23:32:43.627Z
Answers.LastActivityDate: 2015-11-24T23:45:50.707Z
Answers.LastEditDate: 2015-11-24T23:45:50.707Z
Answers.UserDisplayName: carlcs
Body: <p>I want to sort entries by Entry Type in the order they appear when you create/edit entry types in the CP (which can be reordered). I can't seem to find an argument for order() that works. Can this be done?</p>
  
Tags: <entries><entry-type>
Title: Ordering entries by Entry Type
ThreadText: # Ordering entries by Entry Type
  
  (Asked by: username_0 on 2015-11-24)
  
  I want to sort entries by Entry Type in the order they appear when you create/edit entry types in the CP (which can be reordered). I can't seem to find an argument for order() that works. Can this be done?
  
  **Tags:** entries, entry-type
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2015-11-24. Score: 3 | Accepted answer
  
  I don't think you can order by the types order, or get the types in your template (I might be wrong there though), but maybe you don't need to let this be completely dynamic? I guess the user won't be able to add new types or change the order of them after the site is made? If so, couldn't you just make an array of the types and do somthing like this:
  
  ```
  {% set typesInOrder = ['handle1', 'handle2', 'handle3'] %}
  
  {% for type in typesInOrder %}
      {% for entry in craft.entries.type(type) %}
           {{ entry.title }}
      {% endfor %}
  {% endfor %}
  
  ```
  
  There is of course some limitations, especially if you need to paginate the results. And it's bad for performance to do the craft.entries queries several times, especially if you have many entrytypes. Just thought I'd share this in case it's helpful for your usecase.
  
  > **Comments:**
  > **username_2**: username_1, recommend your Preparse plugin! A simple switch conditional `{% switch entry.type %}{% case 'handle1' %}1{% case 'handle2' %}2{% default %}99{% endswitch %}` and you can use `{% set entries = craft.entries.order('myPreparseHandle') %}`.  
  > **username_0**: Yep, that works just fine. The order in this case won't change. Thanks for the idea!  
  
  ---
  
  ### Answer by username_2 on 2015-11-24. Score: 1
  
  You could try it with a MySQL [`CASE`](https://dev.mysql.com/doc/refman/5.7/en/control-flow-functions.html#operator_case) expression in the `order` parameter:
  
  ```
  {% set orderParam = "CASE
      WHEN type = 'handle1' THEN 1
      WHEN type = 'handle2' THEN 2
      WHEN type = 'handle3' THEN 3
      ELSE 99
  END" %}
  
  {% set entries = craft.entries.section('blog').order(orderParam) %}
  
  ```
  
  Another *untested* suggestion is to try and make this dynamic (order similar to CP):
  
  ```
  {% set section = craft.sections.getSectionById(2) %}
  
  {% set orderParam = "CASE" %}
  
  {% for entryType in section.getEntryTypes() %}
      {% set orderParam = orderParam ~ " WHEN type = '" ~ entryType ~ "' THEN " ~ loop.index %}
  {% endfor %}
  
  {% set orderParam = orderParam ~ " ELSE 99 END" %}
  
  ```
  
  
  ---
  
  