title: Reorganizing an array without sort() and doubles
body: <p>I have an array like this named contents:</p>
  
  <pre><code>contents[0]='&lt;button id=' + randomChar0 +' class="btn" onclick="check('+ f + randomChar0 + f +');"&gt;' + randomChar0 + '&lt;/Button&gt;';
  contents[1]='&lt;button id=' + randomChar1 +' class="btn" onclick="check('+ f + randomChar1 + f +');"&gt;' + randomChar1 + '&lt;/Button&gt;';
  contents[2]='&lt;button id=' + randomChar2 +' class="btn" onclick="check('+ f + randomChar2 + f +');"&gt;' + randomChar2 + '&lt;/Button&gt;';
  </code></pre>
  
  <p>I have tried to rearrange it with this code:</p>
  
  <pre><code>function shuffle(array) {
    var currentIndex = array.length, temporaryValue, randomIndex ;
  
    // While there remain elements to shuffle...
    while (0 !== currentIndex) {
  
      // Pick a remaining element...
      randomIndex = Math.floor(Math.random() * currentIndex);
      currentIndex -= 1;
  
      // And swap it with the current element.
      temporaryValue = array[currentIndex];
      array[currentIndex] = array[randomIndex];
      array[randomIndex] = temporaryValue;
    }
  
    return array;
  };
  </code></pre>
  
  <p>calling it like this:</p>
  
  <pre><code>shuffle(contents);
  </code></pre>
  
  <p>from <a href="https://stackoverflow.com/questions/2450954/how-to-randomize-shuffle-a-javascript-array">How to randomize (shuffle) a JavaScript array?</a></p>
  
  <p>But this Method gives me doubles quite often.</p>
  
  <p>Any idea how to make sure the buttons always change their order without any doubling and without using <code>sort()</code>?</p>
  
  <p>I want to rearrange the array to make the buttons in it appear in a different order everytime i output the array. I also dont want any of the buttons appear twice by accident, which means that i need ALL of the buttons to be output in a "random" order.</p>
  
  <p>Update: I just found this <a href="http://jsperf.com/array-shuffle-comparator/12" rel="nofollow noreferrer">test of array shufflings</a>, there are interesting results.</p>