title: Kotlin generate permutations (in order) of list without duplicate elements
body: <p>Is there an easy (and maybe even Kotlin way) to generate all permutations of a given list (containing duplicate elements), which:</p>
  
  <ul>
  <li>Keeps the order of the elements</li>
  <li>Removes all duplicate elements</li>
  <li>Includes all elements</li>
  </ul>
  
  <p>For example:</p>
  
  <p>Given the list: <code>[A, B, C, A, B, D, A]</code>, I would expect the following outcomes:</p>
  
  <p><code>[A, B, C, D]</code>, <code>[A, C, B, D]</code>, <code>[B, C, A, D]</code>, <code>[C, A, B, D]</code>, <code>[C, B, A, A]</code>, <code>[B, C, D, A]</code>,
  <code>...</code> (if there are any more combinations)</p>
  
  <p><strong>The following outcomes are not valid:</strong></p>
  
  <p><code>[A, B, C, A, D]</code> (duplicate A)</p>
  
  <p><code>[A, B, C, A]</code> (duplicate A and missing D)</p>
  
  <p><code>[A, C, D, B]</code> (wrong order)</p>
  
  <p>Thanks for your help.</p>