Random but unique

Dar Scott dsc at swcp.com
Mon Jan 13 17:30:01 EST 2003


On Monday, January 13, 2003, at 11:30 AM, Jim Hurley wrote:

>> sort lines of vChooseFrom by random(10000)  -- or some suitably big
>> number
>> return line 1 to vNumToChoose of vChooseFrom
>>
>
> I see how this works, and it is deliciously simple, but I don't see 
> why. According to the documentation:
>
> "The shortKey is a chunk expression that specifies which part of each 
> line is used as the sort key. "

Here is my guess.  You can probably try some tests to see if it is 
right.

You are missing the very tiny print after "sortKey".  If you look very, 
very, very closely, the doc will read like this:

"The sortKey is an expression, typically a chunk expression that 
specifies ..."

This command:

sort lines of ... by blahBlahBlah

gets a sort key by calling (virtually) this function on each line:

function sortKey each
    return blahBlahBlah
end if

If I'm right, you should be able to do other interesting sorts.

Dar Scott







More information about the use-livecode mailing list