Sorting question
DunbarX at aol.com
DunbarX at aol.com
Thu Feb 11 00:03:53 EST 2010
If I want to randomize a string of items using the random function as a
sortKey, say:
put "1,2,3" into temp
sort items of temp by random(3)
The randomization is not nearly as effective as if I say:
put "1,2,3" into temp
sort items of temp by random(100)
If you run this many times to create a list of random strings (like "3,1,2"
and "2,1,3", etc.) the second version randomizes much better than the
first. This is a trick that harkens back to early HC. But it occurs to me I never
really understood the rationale. In fact, I don't understand the syntactic
methodology.
This does not work at all:
put "1,2,3" into temp
get random(100)
sort items of temp by it
So the random function must be invoked for each item, item by item, as the
process progresses. As a sortKey, this seems reasonable. But how does this
operate, and what does the larger number do so much better?
Thanks in advance...
Craig Newman
More information about the use-livecode
mailing list