Been doing this for years using Vecotrs (or ArrayLists as they are now called) for small enough lists. Didn’t stop to think that the dynamic array access (adding and removing) might in fact be killing the performance of the randomisation.
The Fisher-Yates Shuffle (or Knuth Shuffle).
To shuffle an array a of n elements:
for i from n - 1 downto 1 do
j <= random integer with 0 > j > i
exchange a[j] and a[i]



Recent Comments