Shuffle an array and replace it's keys with GUIDs in javascript
<p>I want to shuffle an array and change the keys over to unique identifiers.</p>

<p>Here is what I have so far which is a mix of a couple of functions I found lying around the Internet.</p>

<pre><code>QuestionSet.prototype.obfusicate = function(data) {
    var o = {};
    util.list(['question', 'answer'], data, o);

    for (var n = 0; n &lt; o.answer.length - 1; n++) {
        var k = n + Math.floor(Math.random() * (o.answer.length - n));
        var temp = o.answer[k];
        o.answer[k] = o.answer[n];
        o.answer[n] = temp;
    }

    // generate a unique id for the key

    return {
        correct: this.guid(), //actually store the first unique id
        question: [o.question, o.answer]
    };
};

QuestionSet.prototype.guid = function() {
    return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
        var r = Math.random()*16|0, v = c == 'x' ? r : (r&amp;0x3|0x8);
        return v.toString(16);
    });
}
</code></pre>

<p>As of right now my plan is to introduce another <code>for(x in o.answers)</code> loop after the shuffle and make it into an associative array with GUIDs acting as the keys. However I'm sure there is a more elegant solution, I just can't come up with it right now.</p>
