Answers.Body: <p>Duplicate? <a href="https://craftcms.stackexchange.com/questions/9032/how-do-i-combine-search-for-categories-and-entries-into-one-set-of-search-result">How do I combine search for categories and entries into one set of search results?</a></p>
  
  <p>You will have to use something like supersort to sort your array.</p>
  
  <pre><code>{% set classesLocations = craft.entries.section('classes')|merge(craft.categories.group('locations'))|supersort('sortAs', '{ startTime }') %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-01-05T08:56:19.440Z
Answers.LastActivityDate: 2016-01-05T20:41:47.877Z
Answers.LastEditDate: 2017-04-13T12:51:00.160Z
Answers.UserDisplayName: Spoeken
Body: <p>I’m trying to merge two query sources (some entries and some categories) but have them ordered by a shared field that is a date field. Here’s what I have so far:</p>
  
  <pre><code>set classesLocations = craft.entries.section('classes')|merge(craft.categories.group('locations'))`
  </code></pre>
  
  <p>I can group by the field of course, but not sure that helps me with ordering.</p>
  
  <p>When I try to use <code>.order('startTime')</code> on the merged object I of course get an error, as they have already been automatically converted to an array to perform the merge rather than remaining as objects. And of course doing the order on both set of objects first doesn’t help, because the merge just tacks the merge on to the end.</p>
  
Tags: <templating><entries><categories><ordering><merge>
Title: Order merged query by shared field
ThreadText: # Order merged query by shared field
  
  (Asked by: username_0 on 2015-12-14)
  
  I’m trying to merge two query sources (some entries and some categories) but have them ordered by a shared field that is a date field. Here’s what I have so far:
  
  ```
  set classesLocations = craft.entries.section('classes')|merge(craft.categories.group('locations'))`
  
  ```
  
  I can group by the field of course, but not sure that helps me with ordering.
  
  When I try to use `.order('startTime')` on the merged object I of course get an error, as they have already been automatically converted to an array to perform the merge rather than remaining as objects. And of course doing the order on both set of objects first doesn’t help, because the merge just tacks the merge on to the end.
  
  **Tags:** templating, entries, categories, ordering, merge
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-01-05. Score: 1
  
  Duplicate? [How do I combine search for categories and entries into one set of search results?](https://craftcms.stackexchange.com/questions/9032/how-do-i-combine-search-for-categories-and-entries-into-one-set-of-search-result)
  
  You will have to use something like supersort to sort your array.
  
  ```
  {% set classesLocations = craft.entries.section('classes')|merge(craft.categories.group('locations'))|supersort('sortAs', '{ startTime }') %}
  
  ```
  
  
  ---
  
  