• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Sort items in a list without OSAXen
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Sort items in a list without OSAXen


  • Subject: Re: Sort items in a list without OSAXen
  • From: Arthur J Knapp <email@hidden>
  • Date: Tue, 04 Sep 2001 09:57:45 -0400

> Subject: Re: Sort items in a list without OSAXen
> Date: Sun, 2 Sep 2001 19:56:52 +0100
> From: Nigel Garvey <email@hidden>

> 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:

[snip]

> That's very nice! :-)
>
> NG

I concur, it's great!!! :)

A slight speed improvement for larger lists can be obtained by
using AppleScript's pattern setting:

>>on getsumofhighestthree(UnsortedList)

>> -- set a to 0 --the lowest possible value in UnsortedList
>> -- set b to a
>> -- set c to a

set {a, b, c} to {0, 0, 0}

>> repeat with eachitem in UnsortedList
>> if (eachitem > a) then

>> -- set c to b
>> -- set b to a
>> -- set a to eachitem

set {c, b, a} to {b, a, eachitem}

>> else if (eachitem > b) then

>> -- set c to b
>> -- set b to eachitem

set {c, b} to {b, eachitem}

>> else if (eachitem > c) then
>> set c to eachitem
>> end if
>> end repeat
>> return a + b + c
>>end getsumofhighestthree



Arthur J. Knapp
http://www.stellarvisions.com
mailto:email@hidden

Hey, check out:
http://homepage.mac.com/richard23/


  • Follow-Ups:
    • Re: Sort items in a list without OSAXen
      • From: Shane Stanley <email@hidden>
  • Prev by Date: Re: Sort items in a list without OSAXen
  • Next by Date: Color HTML link labels.
  • Previous by thread: Re: Sort items in a list without OSAXen
  • Next by thread: Re: Sort items in a list without OSAXen
  • Index(es):
    • Date
    • Thread