title: MongoDB Aggregation: Dedupe by array in subdocuments
body: <p>I have an aggregation query which calculates records by tag combinations this query is working well however it has one issue which is that it duplicates documents for tag combinations that are in different orders e.g. i could have one document with the tags: ['one', 'two'] and a second document with ['two' 'one'] the rest of the data would be exactly the same.</p>
  <p>My first thought would be to do a $group aggregation query and search how to order the arrays in a project query however i cannot find anywhere how to do this. I did see for update queries you can use '$push' however this feature doesnt seem to exist for $project queries.</p>
  <p>an example document at this phase is something like this</p>
  <pre><code>_id: &quot;sadasdsad&quot;
  tags: ['one', 'two'],
  total_count:37,
  second_count:14,
  </code></pre>
  <p>what would be the best approach to solving this issue?</p>