# NSSortDescriptor class documentation

diablos@manga.sk
Generated at 2025-09-10 09:16:48 +0000
2005 Free Software Foundation, Inc.
Software documentation for the NSSortDescriptor class
Foundation/NSSortDescriptor.h
NSCopying
NSCoding
Instances of this class are used to perform multi-level sorts of arrays containging collections or other objects whose properties can be obtained using key names.
sortDescriptorWithKey:
aKey
ascending:
ascending

Returns an autoreleased sort descriptor for comparisons using the 'compare:' selector and the specified key and ordering.

See also -initWithKey:ascending: .

sortDescriptorWithKey:
key
ascending:
ascending
comparator:
cmptr

Returns an autoreleased sort descriptor initialized to perform comparisons in the specified order using the comparator to compare the property aKey of each object.

See also -initWithKey:ascending:selector:.

sortDescriptorWithKey:
aKey
ascending:
ascending
selector:
aSelector

Returns an autoreleased sort descriptor initialized to perform comparisons in the specified order using aSelector to compare the property aKey of each object.

See also -initWithKey:ascending:selector:.

ascending
Returns a flag indicating whether the sort descriptor sorts objects in ascending order ( `YES`) or descending order ( `NO`).
compareObject:
object1
toObject:
object2
Returns the result of comparing object1 to object2 using the property whose key is defined in the receiver and using the selector of the receiver. If the receiver performs a descending order sort, the result of this comparison is the opposite of that prroduced by applying the selector.
initWithKey:
key
ascending:
ascending
Initialises the receiver for comparisons using the 'compare:' selector and the specified key and ordering.
initWithKey:
key
ascending:
ascending
comparator:
cmptr
Initialises the receiver to perform comparisons in the specified order using the comparator to compare the property key of each object.
initWithKey:
key
ascending:
ascending
selector:
selector
Initialises the receiver to perform comparisons in the specified order using selector to compare the property key of each object.
key
Returns the key used to obtain the property on which comparisons are based.
reversedSortDescriptor
Returns a copy of the receiver which compares and sorts in reversed order.
selector
Returns the selector used to compare the properties of objects.
Software documentation for the NSArray(NSSortDescriptorSorting) category
Foundation/NSSortDescriptor.h
Description forthcoming.
sortedArrayUsingDescriptors:
sortDescriptors
Produces a sorted array using the mechanism described for [NSMutableArray(NSSortDescriptorSorting) -sortUsingDescriptors:]
Software documentation for the NSMutableArray(NSSortDescriptorSorting) category
Foundation/NSSortDescriptor.h
Description forthcoming.
sortUsingDescriptors:
sortDescriptors
This method works like this: first, it sorts the entire contents of the array using the first sort descriptor. Then, after each sort-run, it looks whether there are sort descriptors left to process, and if yes, looks at the partially sorted array, finds all portions in it which are equal (evaluate to NSOrderedSame) and applies the following descriptor onto them. It repeats this either until all descriptors have been applied or there are no more equal portions (equality ranges) left in the array.
Software documentation for the NSSet(NSSortDescriptorSorting) category
Foundation/NSSortDescriptor.h
Description forthcoming.
sortedArrayUsingDescriptors:
sortDescriptors
Produces a sorted array from using the mechanism described for [NSMutableArray(NSSortDescriptorSorting) -sortUsingDescriptors:]