Previous Book Contents Book Index Next

Inside Macintosh: AppleScript Finder Guide /
Chapter 3 - Finder Commands / Command Definitions


Sort

The Sort command is a request for a sorted list of references.

SYNTAX
sort referenceList by propertyLabel
PARAMETERS
referenceList
A list of references to the objects that are to be sorted. This may take the form of a single reference to several objects in the same container or a list of references to objects in several containers.
Class: Reference or list of references
propertyLabel
The name of the property by which the objects are to be sorted.
Class: Class identifier
RESULT
A list of references sorted according to the property specified in the propertyLabel parameter.

EXAMPLES
This script returns a list of references to the folders in the startup disk, sorted by creation date:

tell application "Finder"
   sort folders in startup disk by creation date
end tell

--result: {folder "Letters" of startup disk of 
application "Finder", folder "Projects" of startup disk 
of application "Finder", folder "Current Correspondence" of 
startup disk of application "Finder"}
This script sorts files from several different folders by size.

tell application "Finder"
   sort {files in startup disk, files in disk "Data"} �
      by size
end tell

--result: {file "George" of startup disk of application 
"Finder", file "Notes" of disk "Data" of application 
"Finder", file "Expenses" of startup disk of application 
"Finder"}
NOTES
The Sort command usually sorts in ascending order; for example, if you sort by name, the resulting references are sorted alphabetically by name. When you sort by creation date or modification date, the Sort command returns a list of references sorted in descending order from the newest item to the oldest.

To sort the actual items that are displayed in a window, rather than a list of references to those items, either set the View property of the window or, if the items are displayed by icon or by small icon, use the Clean Up command as described on page 106.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
13 JUL 1996