What is the best way to randomize part of the array in Javascript
For example, if I have 100 items in the array, what is the fast and efficient way of randomizing set of
I would just use the built in slice, concat and sort methods. Something like this.
function shuffle(arr, start, end) {
return arr.slice(start, end).sort(function() { return .5 - Math.random(); }).concat(arr.slice(end));
};
That's the basic idea, you probably want to make an algorithm to slice every 10 elements, sort and rejoin the sets.
EDIT: Read comments below for why this solution may not be suitable for your needs.