@botovq was kind enough to point out that although my earlier
implementation produced random-ish ordering, it strictly speaking
wasn't Fisher-Yates.
We need to ensure `j` is a random number between `i` and `list.count`
see the second example in the 'Modern Algorithm'
https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle
/* Fisher-Yates shuffle with modulo bias */
srand(time(NULL) ^ getpid());
- for (i = 0; i < mft->fileList.list.count; i++) {
- j = rand() % mft->fileList.list.count;
+ for (i = 0; i < mft->fileList.list.count - 1; i++) {
+ j = i + rand() % (mft->fileList.list.count - i);
tmpfah = mft->fileList.list.array[j];
mft->fileList.list.array[j] = mft->fileList.list.array[i];
mft->fileList.list.array[i] = tmpfah;