• 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
Sorting lists of strings and lists of lists in Applescript
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Sorting lists of strings and lists of lists in Applescript


  • Subject: Sorting lists of strings and lists of lists in Applescript
  • From: Alastair Leith <email@hidden>
  • Date: Tue, 18 Mar 2014 16:07:16 +1100

I found a "sortlist" command in the applescript dictionary but I can't get it to work for me.

set random_list to {"adam", "penny", "prada", "swati", "teddy", "james"}
set sorted_list to sortlist random_list ¬
ascending true ¬
remove duplicates false ¬
comparison 1

log random_list
log sorted_list

When I pasted the command into Script Debugger it was not wrapped with tell statements but I tried wrapping it in tell application "Finder" in case.
 
There is this comment in the dictionary but I don't know what it refers to — the links are dead:
(from the Array and List Utilities suite, defined in Satimage.osax)

I found a "sortlist" command in the applescript dictionary but I can't get it to work for me.

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).

In short _javascript_ has an inbuilt sort for array objects method: my_array.sort(a,b) does Applescript have anything similar?


 _______________________________________________
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

  • Follow-Ups:
    • Re: Sorting lists of strings and lists of lists in Applescript
      • From: Christopher Stone <email@hidden>
  • Prev by Date: Re: ID of a Disk
  • Next by Date: Re: Sorting lists of strings and lists of lists in Applescript
  • Previous by thread: Re: ID of a Disk
  • Next by thread: Re: Sorting lists of strings and lists of lists in Applescript
  • Index(es):
    • Date
    • Thread