Re: Checking for duplicates in lists
Re: Checking for duplicates in lists
- Subject: Re: Checking for duplicates in lists
- From: Bill <email@hidden>
- Date: Sat, 3 Jan 2004 23:27:41 +0800
Ken,
On 03 Jan 2004, at 16:23, Graff wrote:
You might want to also use the "-f" switch for the sort tool so that
it sorts upper case and lower case the same. Also it is probably
simpler to just use AppleScript's text item delimiters to convert the
AppleScript list to a line-feed delimited list
In the past, there were discussions in this list about troubles "when
text item meets unicode text"; which lead me to avoid using TID to
convert a list into text.
The "-f" option makes funny result (with unicode text?), when it sorts
a list of file name, while some of them are in traditional Chinese, the
result is items in traditional Chinese come before items in English.
--------------
on shellSort(l)
-- set delimiters to line-feed, save old setting
set {oldDelims, text item delimiters} to {text item delimiters, ASCII
character 10}
-- coerce list into line-feed delimited text
set tmp to quoted form of (l as text)
-- reset delimiters to old delimiters
set text item delimiters to oldDelims
-- sort text, remove duplicates
set output to (do shell script "echo " & tmp & " | sort -uf")
-- break up output into a list
return every paragraph of output
end shellSort
Brilliant :)
bill
_______________________________________________
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.