• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
An alternative to "sort" & "uniq"
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: An alternative to "sort" & "uniq"
      • From: "Gary (Lists)" <email@hidden>
  • Prev by Date: Re: File Name Change
  • Next by Date: Re: An alternative to "sort" & "uniq"
  • Previous by thread: Changes from Mac OS X 10.3.8 to 10.3.9
  • Next by thread: Re: An alternative to "sort" & "uniq"
  • Index(es):
    • Date
    • Thread