On Mar 18, 2014, at 00:07, Alastair Leith < email@hidden> wrote: I found a "sortlist" command in the applescript dictionary
______________________________________________________________________
Hey Alastair,
Not exactly. As you note later it's from the Satimage.osax - a 3rd party osax.
but I can't get it to work for me.
Well, that doesn't make sense. Rearranging your list to make the sort even more obvious and then running the exact same sort:
set random_list to {¬ "prada", ¬ "penny", ¬ "swati", ¬ "teddy", ¬ "james", ¬ "adam"}
set sorted_list to sortlist random_list ¬ ascending true ¬ remove duplicates false ¬ comparison 1
--> Result:
{ "adam", "james", "penny", "prada", "swati", "teddy" } When I pasted the command into Script Debugger it was not wrapped with tell statements
Nor should it be. but I tried wrapping it in tell application "Finder" in case.
These days we're told to avoid putting osax-calls within application tell-blocks. There is this comment in the dictionary but I don't know what it refers to — the links are dead:
The links should NOT be dead. If in fact they are it's indicative of something amiss.
Make sure you're using the most recent version of the Satimage.osax.
Even if you are it might be a good idea to reinstall it.
Reboot your system for good measure.
The dictionary description suggests this command will also sort a list of lists using the "with respect to" argument by prioritising the criteria with integers (presumably like a table sort in a spreadsheet app but no example or specification is provided).
The best place to ask questions about the Satimage.osax or Smile is Smile Users List. In short _javascript_ has an inbuilt sort for array objects method: my_array.sort(a,b) does Applescript have anything similar?
No. Nothing built-in, but you can shell out to Perl, Python, Ruby, _javascript_, etc.
-- Best Regards, Chris
|