randomly order a list

Björnke von Gierke bvg at mac.com
Wed May 22 13:17:15 CDT 2013


If you want random sorts, don't change the randomseed. It's set for you on startup, and only should be set if you want non-random things to happen.

If you sort three lines randomly there's a pretty high chance that a given line remains on the same line for two consecutive times. It's not 'always' but often. Three is just not very random to begin with :)

If you want to make sure a given line is at a given place, you should insert it yourself, and not rely on sort, because that's random, and includes your chosen line. For example:

put "option1" & return & "option2" into theLines
sort theLines by random(the number of lines of theLines)
put "option3" & return before line random(2) of theLines --will never be last line

On 22.05.2013, at 19:59, 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
> Read Naturally, Inc.
> www.readnaturally.com
> 
> 
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


-- 

Use an alternative Dictionary viewer:
http://bjoernke.com/bvgdocu/

Chat with other RunRev developers:
http://bjoernke.com/chatrev/





More information about the use-livecode mailing list