Sorting question

Vokey, John vokey at uleth.ca
Thu Feb 11 11:55:24 EST 2010


This function provides for a *truly uniform* random sort:

function scramble x -- scramble lines or items in a row
  put the number of lines of x into z
  if z = 1 then put the number of items of x into n
  else put the number of lines of x into n
  repeat with i=n down to 2
    put random(i) into k
    if z=1 then put item k of x into t
    else put line k of x into t
    if z=1 then put item i of x into item k of x
    else put line i of x into line k of x
    if z=1 then put t into item i of x
    else put t into line i of x
  end repeat
  return x
end scramble
--
Please avoid sending me Word or PowerPoint attachments.
See <http://www.gnu.org/philosophy/no-word-attachments.html>







More information about the Use-livecode mailing list