Re: how to do a proper alphabetical sort?
Re: how to do a proper alphabetical sort?
- Subject: Re: how to do a proper alphabetical sort?
- From: "Mark J. Reed" <email@hidden>
- Date: Thu, 8 Mar 2007 19:38:56 -0500
Oh, and don't forget to restore the delimiters. :) Here's a handler version:
on sortList(unsortedList)
set oldDelimiters to AppleScript's text item delimiters
set AppleScript's text item delimiters to (ASCII character 10)
set sortedList to paragraphs of (do shell script "echo " & quoted
form of (unsortedList as string) & "| sort -d -f")
set AppleScript's text item delimiters to oldDelimiters
return sortedList
end sortList
sortList({"apple", "Arthur", "Carl", "Betty", "candy", "dog"})
On 3/8/07, Mark J. Reed <email@hidden> wrote:
On 3/8/07, Patrik B. <email@hidden> wrote:
> Hi,
>
> I am looking for a library or method that does an alphabetical sort?
I'm sure there's a way to do it with "pure" AS, but you can use the
shell command "sort" to do it:
set unsortedList to { "apple", "Arthur", "Carl", "Betty", "candy", "dog" }
set old_delims to AppleScript's text item delimiters
set AppleScript's text item delimiters to {ASCII character 10}
set sortedList to paragraphs of (do shell script "echo " & quoted form
of (unsortedList as string) & "| sort -d -f")
That gives {"apple", "Arthur", "Betty", "candy", "Carl", "dog"} - not
exactly what you wanted since you specified uppercase before
lowercase, but perhaps good enough?
--
Mark J. Reed <email@hidden>
--
Mark J. Reed <email@hidden>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden