use framework "Foundation"
use BridgePlus : script "BridgePlus"
set someList to {"itemZ", "itemB", "itemA", "itemB", "itemZ"}
# attempt 1
set anArray to Cocoaify someList
set anArray to sortArray(anArray)
set anArray to makeUniqueArray(anArray)
set aList to ASify from (anArray)
# attempt 2
set anArray to sortArray(Cocoaify someList)
set anArray to makeUniqueArray(anArray)
set aList to ASify from (anArray)
# attempt 3
set anArray to sortArray(Cocoaify someList)
set aList to ASify from (my makeUniqueArray(anArray))
# attempt 4
set aList to ASify from (my SortAndMakeUniqueArray(Cocoaify someList))
#=====
on sortArray(anArray)
return anArray's sortedArrayUsingSelector:"compare:"
end sortArray
#=====
on makeUniqueArray(anArray)
set theSet to current application's NSOrderedSet's orderedSetWithArray:anArray
return theSet's allObjects()
end makeUniqueArray
#=====
on SortAndMakeUniqueArray(anArray)
set anArray to anArray's sortedArrayUsingSelector:"compare:"
set theSet to current application's NSOrderedSet's orderedSetWithArray:anArray
return theSet's allObjects()
end SortAndMakeUniqueArray
#=====