shuffle function
Shuffles a list randomly.
A sub-range of a list can be shuffled by providing start
and end
.
Implementation
void shuffle(List list, [int start = 0, int end]) {
var random = new math.Random();
if (end == null) end = list.length;
int length = end - start;
while (length > 1) {
int pos = random.nextInt(length);
length--;
var tmp1 = list[start + pos];
list[start + pos] = list[start + length];
list[start + length] = tmp1;
}
}