Answers.Body: <p><strong>Edit: This strategy still works, but see my <a href="https://craftcms.stackexchange.com/a/36981/689">updated answer</a> for more up-to-date solution.</strong></p>
  <p>Prior to SuperSort 3.1.0, you might achieve this by using the <a href="http://twig.sensiolabs.org/doc/filters/replace.html" rel="nofollow noreferrer"><code>replace</code></a> filter inside SuperSort's micro-template:</p>
  <pre><code>{% set foo = craft.entries.section('foo')... %}
  
  {% set sortedFoo = foo | supersort('sortAs', '{ shopType | replace({
      'ShopType1': &quot;A&quot;,
      'ShopType2': &quot;B&quot;,
      'ShopType3': &quot;C&quot;
  }) }') %}
  </code></pre>
  <p>The first parameter you pass to <em>SuperSort</em> specifies the <strong>sort method</strong>.</p>
  <p>The second parameter provides a <strong>value template</strong> for the sorting function: Under the hood, the system parses <code>{ shopType | replace(...) }</code> — a Craft <a href="http://buildwithcraft.com/classreference/services/TemplatesService#renderObjectTemplate-detail" rel="nofollow noreferrer">'micro-template'</a> — into <code>{{ object.shopType | replace(...) }}</code>. The plugin parses that template by passing in your array item as the <code>object</code> and uses the output value to sort by.)</p>
  <p><em>n.b. You need to specify that replacement list directly in the object template. Passing in a Twig variable doesn't work because the object template doesn't share the same context as the parent template.</em></p>
  <p><strike>The syntax in your original question would actually not be a bad addition for use-cases like this; I'll look into adding something like that to SuperSort when I get some downtime.</strike></p>
  <p><strong>As of SuperSort 3.1.0, you <a href="https://craftcms.stackexchange.com/a/36981/689">can now use a custom-order sort method</a>, similar to what you originally suggested.</strong></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-01-12T20:59:51.133Z
Answers.Text: I wanted to implement this, but this doesn’t seem to work.. has the syntax changed since 2015?
Answers.UserDisplayName: M Smith
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2015-08-18T13:34:47.203Z
Answers.LastActivityDate: 2021-01-13T17:48:41.353Z
Answers.LastEditDate: 2021-01-13T17:48:41.353Z
Answers.UserDisplayName: Michael Rog
Answers.Body: <p><strong>As of SuperSort 3.1.0, you can use the <code>customOrderSort</code> and <code>customOrderSortAs</code> methods to accomplish this:</strong></p>
  <pre><code>{% set shops = craft.entries.section('shops')... %}
  
  {% set customOrderList = [
      'SomeShopType',
      'AnotherShopType',
      'OneMoreShopType'
  ] %}
  
  {% set sortedShops = shops
      | supersort('customOrderSortAs', as='{shopType}', comp=customOrderList) %}
  
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-01-13T17:43:22.643Z
Answers.LastActivityDate: 2021-01-13T17:43:22.643Z
Answers.UserDisplayName: Michael Rog
Body: <p>I want to sort an array of entries in a specific order. Every entry has a 'shoptype' and I want to show all entries for type A, than type B, than type C.</p>
  
  <p>A partial solution would be to iterate over them <code>(if shoptype == A){ then show all A entries}</code> but than I can't write a conditonal around it to hide the title when there are no shops of type A.</p>
  
  <p>So now I group them using the group twig filter and hide if the group has no items. But I can't sort them the way I like (it's not alphabetical, it's a fixed order that I want).</p>
  
  <p>Idealy I would need something like this in supersort: </p>
  
  <pre><code>'SortAs', ['shoptype A', 'shoptype B', 'shoptype C']
  </code></pre>
  
  <p>So an array of strings that my shopType field can contain which my array is grouped by.</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-08-18T13:31:32.560Z
Comments.Text: Hi Tom, this page might give you a good start: http://buildwithcraft.com/help/entry-archive
Comments.UserDisplayName: Jamie Wade
Tags: <sorting><plugin-supersort>
Title: Sorting an array of entries according to a fixed list/array of items
ThreadText: # Sorting an array of entries according to a fixed list/array of items
  
  (Asked by: username_0 on 2015-08-18)
  
  I want to sort an array of entries in a specific order. Every entry has a 'shoptype' and I want to show all entries for type A, than type B, than type C.
  
  A partial solution would be to iterate over them `(if shoptype == A){ then show all A entries}` but than I can't write a conditonal around it to hide the title when there are no shops of type A.
  
  So now I group them using the group twig filter and hide if the group has no items. But I can't sort them the way I like (it's not alphabetical, it's a fixed order that I want).
  
  Idealy I would need something like this in supersort:
  
  ```
  'SortAs', ['shoptype A', 'shoptype B', 'shoptype C']
  
  ```
  
  So an array of strings that my shopType field can contain which my array is grouped by.
  
  **Tags:** sorting, plugin-supersort
  
  > **Comments:**
  > **username_1**: Hi Tom, this page might give you a good start: http://buildwithcraft.com/help/entry-archive  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2015-08-18. Score: 3
  
  **Edit: This strategy still works, but see my [updated answer](https://craftcms.stackexchange.com/a/36981/689) for more up-to-date solution.**
  
  Prior to SuperSort 3.1.0, you might achieve this by using the [`replace`](http://twig.sensiolabs.org/doc/filters/replace.html) filter inside SuperSort's micro-template:
  
  ```
  {% set foo = craft.entries.section('foo')... %}
  
  {% set sortedFoo = foo | supersort('sortAs', '{ shopType | replace({
      'ShopType1': "A",
      'ShopType2': "B",
      'ShopType3': "C"
  }) }') %}
  
  ```
  
  The first parameter you pass to *SuperSort* specifies the **sort method**.
  
  The second parameter provides a **value template** for the sorting function: Under the hood, the system parses `{ shopType | replace(...) }` — a Craft ['micro-template'](http://buildwithcraft.com/classreference/services/TemplatesService#renderObjectTemplate-detail) — into `{{ object.shopType | replace(...) }}`. The plugin parses that template by passing in your array item as the `object` and uses the output value to sort by.)
  
  *n.b. You need to specify that replacement list directly in the object template. Passing in a Twig variable doesn't work because the object template doesn't share the same context as the parent template.*
  
  The syntax in your original question would actually not be a bad addition for use-cases like this; I'll look into adding something like that to SuperSort when I get some downtime.
  
  **As of SuperSort 3.1.0, you [can now use a custom-order sort method](https://craftcms.stackexchange.com/a/36981/689), similar to what you originally suggested.**
  
  > **Comments:**
  > **username_3**: I wanted to implement this, but this doesn’t seem to work.. has the syntax changed since 2015?  
  
  ---
  
  ### Answer by username_2 on 2021-01-13. Score: 1
  
  **As of SuperSort 3.1.0, you can use the `customOrderSort` and `customOrderSortAs` methods to accomplish this:**
  
  ```
  {% set shops = craft.entries.section('shops')... %}
  
  {% set customOrderList = [
      'SomeShopType',
      'AnotherShopType',
      'OneMoreShopType'
  ] %}
  
  {% set sortedShops = shops
      | supersort('customOrderSortAs', as='{shopType}', comp=customOrderList) %}
  
  ```
  
  
  ---
  
  