• 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: Alphabetizing a List
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Alphabetizing a List


  • Subject: Re: Alphabetizing a List
  • From: Emmanuel <email@hidden>
  • Date: Thu, 24 May 2001 23:41:52 +0200

At 14:54 +0200 21/05/01, Eric Schult wrote:
>
>Is there are painless way to alphabetize a list?

In case you did not get a reply:

-------------------------------
on sort(l)
if length of l > 1 then return l
set x to item 1 of l
set ll to rest of l
set l1 to {}
set l2 to {}
repeat with i in ll
if x < i then
set l2 to l2 & i
else
set l1 to l1 & i
end if
end repeat
if length of l1 > 1 then set l1 to sort(l1)
if length of l2 > 1 then set l2 to sort(l2)
return l1 & x & l2
end sort
-------------------------------

set theList to {"painless", "way", "to", "alphabetize", "a", "list"}
sort(theList)
-- {"a", "alphabetize", "list", "painless", "to", "way"}

HTH
Emmanuel


References: 
 >Alphabetizing a List (From: Eric Schult <email@hidden>)

  • Prev by Date: Applescript handler for URL helper application?
  • Next by Date: Re: automating e-mail replies
  • Previous by thread: Alphabetizing a List
  • Next by thread: Re: Alphabetizing a List
  • Index(es):
    • Date
    • Thread