Sorting question, at rest
DunbarX at aol.com
DunbarX at aol.com
Thu Feb 11 17:45:01 EST 2010
Peter.
I think I now see the difference when a random sortkey is used to
randomize, as opposed to simply creating a random list from data:
put "1,2,3" into temp
repeat 100
put item random(3) of temp & return after myList --works well
end repeat
is very different than:
put "1,2,3" into temp
repeat 100
sort items of temp by random(3)
put temp & return after myList -- hardly works at all
end repeat
I saw them as similar. I was wrong.
Craig Newman
In a message dated 2/11/10 11:23:00 AM, pmbrig at gmail.com writes:
> Brian Yennie gave the explanation. When you use random(3) as a sort
> key you have a high chance (in fact I think it's 50%) that two of the
> items will be assigned the same sort key, and thus their relative
> position will be preserved, giving a decidedly non-random sort. If you
> sort by random(1000000) or some suitably high number the chances of
> getting the same sortkey in your three iterations is miniscule.
>
More information about the use-livecode
mailing list