Re: Automatically sort a list ?
Re: Automatically sort a list ?
- Subject: Re: Automatically sort a list ?
- From: Ben Waldie (AppleScript Guru) <email@hidden>
- Date: Sun, 26 Jan 2003 17:39:06 -0500
Thomas,
On Sunday, January 26, 2003, at 05:01 PM, Thomas wrote:
>
Hi, is there a way to automatically sort a list by alphabetic order ?
>
This script gives me playlists name of iTunes with an order that
>
eludes me :
>
>
tell application "iTunes"
>
name of every playlist
>
end tell
Here's a subroutine from the AppleScript web site, which will sort a
list of strings. You can pass your playlist to it...
set the composer_list to {"Ellington", "Copland", "Bach", "Mozart"}
return ASCII_Sort(the composer_list)
on ASCII_Sort(my_list)
set the index_list to {}
set the sorted_list to {}
repeat (the number of items in my_list) times
set the low_item to ""
repeat with i from 1 to (number of items in my_list)
if i is not in the index_list then
set this_item to item i of my_list as text
if the low_item is "" then
set the low_item to this_item
set the low_item_index to i
else if this_item comes before the low_item then
set the low_item to this_item
set the low_item_index to i
end if
end if
end repeat
set the end of sorted_list to the low_item
set the end of the index_list to the low_item_index
end repeat
return the sorted_list
end ASCII_Sort
Thanks,
- Ben
Benjamin S. Waldie
AppleScript Guru
http://www.applescriptguru.com
http://www.applescripttraining.com
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.