At 6:39 PM -0600 9/2/00, Brad Waite wrote:
>Yep, figured it out. But I don't understand why one has to sort it when it's
>already sorted... Is there a 'sorted' flag somewhere in the member internals?
Lists have an internal flag (not accessible through Lingo) which indicates
their sort status. I wrote the following routine for
http://www.director8.com/ which you might find useful:
-- this Lingo handler function examines a passed linear or property list
-- and return a boolean result as to whether the list is in a sorted state
-- written by Terry R. Schussler on 11/12/97
-- slightly updated on 9/2/2000 for dot notation syntax
-- NOTE: Lists must have at least one value. Empty lists will be
considered sorted.
on sortP listArg
-- we assume that ASCII 0 will always be sorted into the first position
firstPositionToken = numToChar(0)
-- check the list type
case (ilk(listArg)) of
#list : -- check a linear list's sorted state
add listArg, firstPositionToken
firstEntry = listArg[1]
#propList : -- check a property list's sorted state
addProp listArg, firstPositionToken, firstPositionToken
firstEntry = listArg[1]
otherwise
-- the passed argument was NOT a list value
return #ERR
end case
-- determine where our temporary entry was added to determine sort state
if firstEntry = firstPositionToken then
deleteAt listArg, 1
return TRUE
else
deleteAt listArg, count(listArg)
return FALSE
end if
end sortP
---- Test run:
list = [1,2,3]
put sortP(list)
-- 0
sort list
put sortP(list)
-- 1
Regards,
Terry
--
...---===| Terry R. Schussler |===---...
...---===| DIA Chief Investigator |===---...
on visitWebsite yourSelection
coolSites = [ \
#greatSeminars : "http://www.macromediaseminars.com/", \
#directorIntelligenceAgency: "http://www.director8.com", \
#freeBehaviors : "http://www.behaviors.com/"]
gotoNetPage coolSites.yourSelection
end visitWebsite
[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/LUJ/lingo-l.cgi To post messages to the list,
email [EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED])
Lingo-L is for learning and helping with programming Lingo. Thanks!]