var randInt = require('../random/randInt'); /** * Shuffle array items. */ function shuffle(arr) { var results = [], rnd; if (arr == null) { return results; } var i = -1, len = arr.length; while (++i < len) { if (!i) { results[0] = arr[0]; } else { rnd = randInt(0, i); results[i] = results[rnd]; results[rnd] = arr[i]; } } return results; } module.exports = shuffle;