|
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] |
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, 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
| References: | |
| >how to do a proper alphabetical sort? (From: "Patrik B." <email@hidden>) | |
| >Re: how to do a proper alphabetical sort? (From: "Mark J. Reed" <email@hidden>) |
| Home | Archives | Terms/Conditions | Contact | RSS | Lists | About |
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE
Contact Apple | Terms of Use | Privacy Policy
Copyright © 2011 Apple Inc. All rights reserved.