Alternate Random Sort?
Sarah Reichelt
sarah.reichelt at gmail.com
Fri Jul 14 17:01:09 EDT 2006
> I have a list of 14,000 numbers that consists of only 1's and 2's:
> 1
> 1
> 1
> 2
> 2
> 2
> 2
>
> I want to randomize the list. When I use:
>
> sort lines of mySet by random(the number of lines of mySet)
>
> ...the time needed is too slow (takes about 7 seconds to execute here). Is
> there a faster way to randomize the list? (the numbers could also be stored
> by item if that would help: 1,1,1,1,2,2,2,2,2)
>
> Here's a sample script:
>
> on mouseUp
> repeat 6000
> put 1 & cr after temp
> end repeat
> repeat 8000
> put 2 & cr after temp
> end repeat
> delete last char of temp
> put the millisecs into MS
> sort lines of temp by random(the number of lines of temp)
> put the millisecs - MS
> end mouseUp
Instead of asking it to compute the length of your list for every
line, how about just using:
sort lines of temp by random(10000000)
or some suitably large number?
Cheers,
Sarah
More information about the use-livecode
mailing list