Random sort demonstration
dochawk at gmail.com
Thu May 23 09:36:52 CDT 2013
On Thu, May 23, 2013 at 6:51 AM, Richard Gaskin
<ambassador at fourthworld.com> wrote:
> Wouldn't that put the probability of sorting bottom-to-top unusually high,
> since there the odds are 4294967292-to-1 that the sort integer will exceed
> the number of lines in the list?
If I'm reading the prior posts right, that won't be a problem, because
all of the lines will have such a number.
Whereas for a small list, there could indeed be a problem: if numbers
from 1 to three are being generated, there is only a 1/3 chance that
all of the numbers from 1 to 3 are generated (1*2/3*1/3).
There is also a 1/3 chance that the same number is generated three
In such cases, the order of the affected lines (the ones with the
multiply drawn number) would not change (e.g., if both have "2", they
will both be left where they are). Put another way, 2/3 of the time,
one or more lines will not be subject to sort.
That said, sorting three lines by random(3) is not going to give
random results. A number that is large compared to the lines sorted
Dr. Richard E. Hawkins, Esq.
More information about the use-livecode