Simple Alphabetization script

Here’s a little script I wrote today to alphabetize a list. I now know there’s a better (faster) way to do it with shell scripting, but I thought I’d share anyway! :slight_smile:

-- Simple Alphabetizing script (to the second character)
set my_list to {"zoo", "monkey", "elephant", "alligator", "aardvark", "ape", "dog", "dingo", "cat", "butterfly", "ant", "zebra", "panda", "moose"} -- sample List
set my_alphabet to "abcdefghijklmnopqrstuvwxyz" -- sort string
set new_list to {}

--Begin Sorting
repeat with letter from 1 to (count of my_alphabet)
	repeat with letter2 from 1 to (count of my_alphabet)
		repeat with n from 1 to (count of my_list)
			if (character 1 of item n of my_list is equal to character letter of my_alphabet) and (character 2 of item n of my_list is equal to character letter2 of my_alphabet) then
				set new_list to new_list & item n of my_list
			end if
		end repeat
	end repeat
end repeat

return new_list