An alternative to "sort" & "uniq"
An alternative to "sort" & "uniq"
- Subject: An alternative to "sort" & "uniq"
- From: Martin Orpen <email@hidden>
- Date: Mon, 18 Apr 2005 10:47:09 +0100
Title: An alternative to "sort" & "uniq"
More fun with Daniel's AppleScriptKit:
set theList to {}
repeat 1000 times
set end of theList to random number from 1 to 1000
end repeat
procArray(theList)
on procArray(myArray)
tell application "AppleScriptKit"
set theArray to call method "arrayWithArray:" of class "NSArray" with parameter myArray
set sArray to call method "distinct" of myArray
end tell
end procArray
-->{4.0, 5.0, 6.0, 9.0, 10.0, 12.0, 13.0, 14.0...
If you keep the random number maximum equal to or less than the number of items in the list the result appears to always be returned sorted.
I’m sure that there must be a method of returning the minimum & maximum items from the list, but couldn’t work out how :-(
Works with text too – but doesn’t sort the result.
--
Martin Orpen
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden