Re: sort a list and remove duplicate
Re: sort a list and remove duplicate
- Subject: Re: sort a list and remove duplicate
- From: Shane Stanley <email@hidden>
- Date: Sat, 23 May 2015 15:01:16 +1000
On 23 May 2015, at 12:45 am, Yvan KOENIG <email@hidden> wrote:
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
FWIW, you could probably improve that slightly by making the set before doing the sort -- that potentially means you end up with fewer items to sort. It also means you can use a plain set rather than an ordered set. So:
on SortAndMakeUniqueArray(anArray) set theSet to current application's NSSet's setWithArray:anArray set anArray to theSet's allObjects() return anArray's sortedArrayUsingSelector:"compare:" end SortAndMakeUniqueArray
|
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden