1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | 1 1 1 1 7 1 6 6 6 1 1 | define(['../random/randInt', './forEach'], function (randInt, forEach) { /** * Shuffle array items. */ function shuffle(arr) { var result = [], rnd; forEach(arr, function(val, i, arr){ if (!i) { result[0] = val; } else { rnd = randInt(0, i); result[i] = result[rnd]; result[rnd] = val; } }); return result; } return shuffle; }); |