Previous Index Next

BridgePlus.framework, SMSForder Class Methods

Category

List manipulation methods

Method

sortedArrayFrom:byKeys:

Summary

Pass an array of items, and have them sorted by the keys, in oder.

Signature

+ (NSArray *)sortedArrayFrom:(NSArray *)listOrArray byKeys:(NSArray *)sortKeys

Parameters

listOrArray = list or array

sortKeys = list of keys to sort on, in order

Result

Sorted result

Availability

Version 1.3.0

Notes

 

Sample

use scripting additions

use framework "Foundation"

use script "BridgePlus"

load framework


set listOrArray to {"one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten"}

set theResult to current application's SMSForder's sortedArrayFrom:listOrArray byKeys:{"length", "self"}

ASify from theResult

--> {"one", "six", "ten", "two", "five", "four", "nine", "eight", "seven", "three"}

theResult as list

--> {"one", "six", "ten", "two", "five", "four", "nine", "eight", "seven", "three"}


set listOrArray to current application's SMSForder's resourceValuesForKeys:{current application's NSURLCreationDateKey} forFilesIn:(path to desktop) recursive:true

set theResult to current application's SMSForder's sortedArrayFrom:listOrArray byKeys:{current application's NSURLCreationDateKey}

set theResult to theResult's valueForKey:(current application's NSURLPathKey)

ASify from theResult

--> list of POSIX paths in creation date order

theResult as list

--> list of POSIX paths in creation date order


Click here to open script in a script editor