randomly order a list

Dar Scott dsc at swcp.com
Wed May 22 19:23:08 EDT 2013

Here is (I think) the situation for random(3).

Lines will be (virtually) assigned numbers randomly; there are 27 possibilities.

There are 9 cases in which the first line is assigned a 1.  It is first in the sort.
There are 4 cases in which the first line is assigned a 2 and the other lines get 2 or 3.  It is first in the sort
There is one case in which all get a 3.  Again, the first line comes in first.

So, assuming my math is good, that means the first line comes in first 14 out of 27 times.  That is 52% and should match what people are getting empirically.

This doesn't address broken random(), though.  It just emphasizes the importance of the big number for random().

Dar

On May 22, 2013, at 11:59 AM, Chris Sheffield wrote:

> I have a list of three words that I need to be randomly sorted. To start with, the first word is the correct answer to a question. I want to re-order the list so that the correct answer may be the second or third word, and not necessarily the first. How can I do this successfully every time? The docs give an example like this:
>
> 	sort lines of myVar by random(the number of lines of myVar)
>
> But this only seems to work successfully one time. After that, the list is always set so the first word is the correct answer. So then I tried randomly setting the randomSeed value, since this value is supposed to affect the random() function and the any keyword, but this didn't seem to make much difference except to change it so either the second or third word is *always* the right answer. I need it to be more mixed up than that.
>
> So does anyone have a good way to do this?
>
> Thanks,
> Chris
>
>
> --
> Chris Sheffield