Re: Sort items in a list without OSAXen
Re: Sort items in a list without OSAXen
- Subject: Re: Sort items in a list without OSAXen
- From: Nigel Garvey <email@hidden>
- Date: Sun, 2 Sep 2001 19:56:52 +0100
has wrote on Sun, 2 Sep 2001 18:41:06 +0100:
>
Here's a handler that'll return the sum of the three highest numbers in
>
UnsortedList:
>
>
>
on getsumofhighestthree(UnsortedList)
>
set a to 0 --the lowest possible value in UnsortedList
>
set b to a
>
set c to a
>
repeat with eachitem in UnsortedList
>
if (eachitem > a) then
>
set c to b
>
set b to a
>
set a to eachitem
>
else if (eachitem > b) then
>
set c to b
>
set b to eachitem
>
else if (eachitem > c) then
>
set c to eachitem
>
end if
>
end repeat
>
return a + b + c
>
end getsumofhighestthree
That's very nice! :-)
NG