• 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: Fastest Sort for text and numbers
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Fastest Sort for text and numbers


  • Subject: Re: Fastest Sort for text and numbers
  • From: "Arthur J Knapp" <email@hidden>
  • Date: Mon, 30 Apr 2001 13:45:44 -0400

> From: "Bourque, Jason" <email@hidden>
> Subject: Fastest Sort for text and numbers
> Date: Mon, 30 Apr 2001 10:58:50 -0400

> I know this has come up before but I can't find the thread for it.
>
> Does anyone have the sorting routine that was deemed the fastest?

I don't recall a specific thread, but this is my favorite stand-by:

set myList to {4, 2, 1, 8, 3, 0, 7, 5, 9, 6}

qSort(myList, 1, myList's length)

myList
-- > {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}


to qSort(lst, l, r)
set {a, z, v} to {l, r, lst's item ((l + r) div 2)}
repeat until z is less than or equal to a
repeat while item a of lst < v
set a to a + 1
end repeat
repeat while item z of lst > v
set z to z - 1
end repeat
if a is less than or equal to z then
set {lst's item z, lst's item a, a, z} to ,
{lst's item a, lst's item z, a + 1, z - 1}
end if
end repeat
if l < z then qSort(lst, l, z)
if r > a then qSort(lst, a, r)
end qSort



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

Hey, check out:
http://www.AppleScriptSourceBook.com


  • Prev by Date: Re: move font file from font folder
  • Next by Date: RE: Fastest Sort for text and numbers
  • Previous by thread: Re: Fastest Sort for text and numbers
  • Next by thread: RE: Fastest Sort for text and numbers
  • Index(es):
    • Date
    • Thread