Previous | Index | Next |
List manipulation methods
sortedArrayFrom:byKeys:
Pass an array of items, and have them sorted by the keys, in oder.
+ (NSArray *)sortedArrayFrom:(NSArray *)listOrArray byKeys:(NSArray *)sortKeys
listOrArray = list or array
sortKeys = list of keys to sort on, in order
Sorted result
Version 1.3.0
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