Answers.Body: <p>So, this is what I ended up with, thanks @douglas-mcdonald and @carlcs</p>
  
  <pre><code>{% set stuck = craft.entries.section('meetings').relatedTo(subcategory).sticky('1').order('meetingDate desc').find() %}
  {% set entries = craft.entries.section('meetings').relatedTo(subcategory).order('meetingDate desc').limit(2).find() %}
  {% set idArray=[] %} 
  {% for entry in entries %}
      {% set idArray = idArray|merge([entry.id]) %}
  {% endfor %}
  {% for entry in stuck %}
      {% set idArray = idArray|merge([entry.id]) %}
  {% endfor %}
  {% set unique=[] %} 
  {% for entry in idArray %}
      {% if entry not in unique %}
          {% set unique = unique|merge([entry]) %}
      {% endif %} 
  {% endfor %}
  {% set publish=[] %}
  {% for entry in unique %}
    {% set publishItem = craft.entries.id(entry).first() %}
    {% set publish = publish|merge([publishItem]) %}
  {% endfor %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-01T11:03:06.903Z
Answers.Text: I think you are doing more work than needed. You can grab the ids using the `ids()` method, and then merge them if not already in array. Then grab all the entries properly sorted by meetingDate using the ids. See [updated answer](http://craftcms.stackexchange.com/a/9543/784).
Answers.UserDisplayName: Douglas McDonald
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-01T20:41:48.140Z
Answers.Text: Ah, right - thanks - I'm not that familiar with retrieving data - that is a lot simpler!
Answers.UserDisplayName: Jack McKenzie
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-01T09:19:51.407Z
Answers.LastActivityDate: 2015-05-01T09:19:51.407Z
Answers.UserDisplayName: Jack McKenzie
Answers.Body: <p>One method is to check to see if item is not in array before merging. The downside is that the entries will just be appended vs sorted by meetingDate.</p>
  
  <pre><code>{% set stuck = craft.entries.section('meetings').relatedTo(subcategory).sticky('1').order('meetingDate desc').find() %}
  {% set entries = craft.entries.section('meetings').relatedTo(subcategory).order('meetingDate desc').limit(2).find() %}
  
  {% for stuckEntry in stuck %}
      {% if stuckEntry not in entries %}
          {% set entries = entries|merge([stuckEntry]) %}
      {% endif %}
  {% endfor %}
  </code></pre>
  
  <p>The other method is to grab the ids from the 2 queries and then merge them together, and perform a new query which can be sorted.</p>
  
  <pre><code>{% set stuckIds = craft.entries.section('meetings').relatedTo(subcategory).sticky('1').ids() %}
  {% set entryIds = craft.entries.section('meetings').relatedTo(subcategory).limit(2).ids() %}
  
  {% for id in stuckIds %}
      {% if id not in entryIds %}
          {% set entryIds = entryIds|merge([id]) %}
      {% endif %}
  {% endfor %}
  
  {% set entries = craft.entries.id(entryIds).order('meetingDate desc') %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-01T01:46:31.227Z
Answers.Text: Thanks, I already tried that - but for some reason stuckEntry always gets added to the entries array, so it ends up there twice. i.e. {% if stuckEntry not in entries %} gets evaluated as true so it seems that the array items are somewhat different.
Answers.UserDisplayName: Jack McKenzie
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-01T02:47:53.127Z
Answers.Text: That's very strange... I've definitely used that technique in the past. Worst case, you can get the ids, then do another query just using the ids.
Answers.UserDisplayName: Douglas McDonald
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-01T06:49:36.210Z
Answers.Text: Yes, it is, and I can't troubleshoot why - I used your code snippet exactly (which was in effect the same as mine). Your idea of using the ids works, but seems like a complicated workaround. But I thank you for offering me a solution.
Answers.UserDisplayName: Jack McKenzie
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-01T07:26:29.633Z
Answers.Text: The ID approach is the way to go if you want your last items sorted into that array of sticky posts and not just appended to it, @Jack.
Answers.UserDisplayName: carlcs
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-01T00:53:53.837Z
Answers.LastActivityDate: 2015-05-01T11:04:34.763Z
Answers.LastEditDate: 2015-05-01T11:04:34.763Z
Answers.UserDisplayName: Douglas McDonald
Body: <p>I have a list of "meetings" as entries and I want to show only the last two ordered by meetingDate, and show any other meetings marked as sticky, without doubling up.</p>
  
  <p>What I have so far is:</p>
  
  <pre><code>{% set stuck = craft.entries.section('meetings').relatedTo(subcategory).sticky('1').order('meetingDate desc').find() %}
  {% set entries = craft.entries.section('meetings').relatedTo(subcategory).order('meetingDate desc').limit(2).find() %}
  {% set entries = entries|merge(stuck) %}
  </code></pre>
  
  <p>Now this works except that if an entry marked as Sticky is one of the first two, then it shows twice. I understand it is bad practice to try and manipulate data using Twig, and that rather I should aim on getting the right data out of the entries first up. </p>
  
Tags: <entries><lightswitch>
Title: How do I limit entries retrieved except those with a sticky lightswitch on the entry?
ThreadText: # How do I limit entries retrieved except those with a sticky lightswitch on the entry?
  
  (Asked by: username_0 on 2015-04-30)
  
  I have a list of "meetings" as entries and I want to show only the last two ordered by meetingDate, and show any other meetings marked as sticky, without doubling up.
  
  What I have so far is:
  
  ```
  {% set stuck = craft.entries.section('meetings').relatedTo(subcategory).sticky('1').order('meetingDate desc').find() %}
  {% set entries = craft.entries.section('meetings').relatedTo(subcategory).order('meetingDate desc').limit(2).find() %}
  {% set entries = entries|merge(stuck) %}
  
  ```
  
  Now this works except that if an entry marked as Sticky is one of the first two, then it shows twice. I understand it is bad practice to try and manipulate data using Twig, and that rather I should aim on getting the right data out of the entries first up.
  
  **Tags:** entries, lightswitch
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2015-05-01. Score: 4 | Accepted answer
  
  One method is to check to see if item is not in array before merging. The downside is that the entries will just be appended vs sorted by meetingDate.
  
  ```
  {% set stuck = craft.entries.section('meetings').relatedTo(subcategory).sticky('1').order('meetingDate desc').find() %}
  {% set entries = craft.entries.section('meetings').relatedTo(subcategory).order('meetingDate desc').limit(2).find() %}
  
  {% for stuckEntry in stuck %}
      {% if stuckEntry not in entries %}
          {% set entries = entries|merge([stuckEntry]) %}
      {% endif %}
  {% endfor %}
  
  ```
  
  The other method is to grab the ids from the 2 queries and then merge them together, and perform a new query which can be sorted.
  
  ```
  {% set stuckIds = craft.entries.section('meetings').relatedTo(subcategory).sticky('1').ids() %}
  {% set entryIds = craft.entries.section('meetings').relatedTo(subcategory).limit(2).ids() %}
  
  {% for id in stuckIds %}
      {% if id not in entryIds %}
          {% set entryIds = entryIds|merge([id]) %}
      {% endif %}
  {% endfor %}
  
  {% set entries = craft.entries.id(entryIds).order('meetingDate desc') %}
  
  ```
  
  > **Comments:**
  > **username_0**: Thanks, I already tried that - but for some reason stuckEntry always gets added to the entries array, so it ends up there twice. i.e. {% if stuckEntry not in entries %} gets evaluated as true so it seems that the array items are somewhat different.  
  > **username_1**: That's very strange... I've definitely used that technique in the past. Worst case, you can get the ids, then do another query just using the ids.  
  > **username_0**: Yes, it is, and I can't troubleshoot why - I used your code snippet exactly (which was in effect the same as mine). Your idea of using the ids works, but seems like a complicated workaround. But I thank you for offering me a solution.  
  > **username_2**: The ID approach is the way to go if you want your last items sorted into that array of sticky posts and not just appended to it, @username_0.  
  
  ---
  
  ### Answer by username_0 on 2015-05-01. Score: 0
  
  So, this is what I ended up with, thanks @username_1-username_1 and @username_2
  
  ```
  {% set stuck = craft.entries.section('meetings').relatedTo(subcategory).sticky('1').order('meetingDate desc').find() %}
  {% set entries = craft.entries.section('meetings').relatedTo(subcategory).order('meetingDate desc').limit(2).find() %}
  {% set idArray=[] %} 
  {% for entry in entries %}
      {% set idArray = idArray|merge([entry.id]) %}
  {% endfor %}
  {% for entry in stuck %}
      {% set idArray = idArray|merge([entry.id]) %}
  {% endfor %}
  {% set unique=[] %} 
  {% for entry in idArray %}
      {% if entry not in unique %}
          {% set unique = unique|merge([entry]) %}
      {% endif %} 
  {% endfor %}
  {% set publish=[] %}
  {% for entry in unique %}
    {% set publishItem = craft.entries.id(entry).first() %}
    {% set publish = publish|merge([publishItem]) %}
  {% endfor %}
  
  ```
  
  > **Comments:**
  > **username_1**: I think you are doing more work than needed. You can grab the ids using the `ids()` method, and then merge them if not already in array. Then grab all the entries properly sorted by meetingDate using the ids. See [updated answer](http://craftcms.stackexchange.com/a/9543/784).  
  > **username_0**: Ah, right - thanks - I'm not that familiar with retrieving data - that is a lot simpler!  
  
  ---
  
  