Hey JM,
There are many shell commands just like that — powerful and concise. That's why I decided to learn at least the basics of shell scripting 8 or 9 years ago.
True.
AppleScriptObjC is not as concise as sort
, but it's really not bad at all:
------------------------------------------------------------------------------
# Auth: Christopher Stone { Heavy Lifting by Shane Stanley }
# dCre: 2017/11/22 10:55
# dMod: 2017/11/22 10:57
# Appl: AppleScriptObjC
# Task: Sort a list of type text and remove duplicates.
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @ccstone, @ASObjC, @Sort, @List, @Remove, @Duplicates
------------------------------------------------------------------------------
use AppleScript version "2.4"
use framework "Foundation"
use scripting additions
------------------------------------------------------------------------------
set theList to {"one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "two"}
set sortedUniqueList to SortAndMakeUniqueArray(theList)
------------------------------------------------------------------------------
--» HANDLERS
------------------------------------------------------------------------------
on SortAndMakeUniqueArray(anArray)
set theSet to current application's NSSet's setWithArray:anArray
set anArray to theSet's allObjects()
return (anArray's sortedArrayUsingSelector:"compare:") as list
end SortAndMakeUniqueArray
------------------------------------------------------------------------------
Then of course there's the Satimage.osax:
set theList to {"One", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "two"}
set sortedUniqueList to sortlist theList comparison 1 with remove duplicates
--> {"eight", "five", "four", "nine", "One", "seven", "six", "ten", "three", "two"}
Comparison 1 makes the sort case-insensitive.
-Chris