Say we have an NSArray named employees which contains Employee objects. The Employee object has a property named startDate. We can very easily sort this array by the start date using an NSSortDescriptor.
First we create the sort descriptor, assign it a key in which to sort on, and specify how we would like the array sorted.
NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"startDate" ascending:YES];
Now we create a new sorted array from the employees array using the sortedArrayUsingDescriptors: method. This method accepts an array of sort descriptors.
NSArray *sortedEmployees = [employees sortedArrayUsingDescriptors:@[sortDescriptor]];
With the introduction of blocks in iOS 4 and Mac OS 10.6, we can do this same task slightly different.
NSArray *sortedEmployees = [employees sortedArrayUsingComparator:^NSComparisonResult(id a, id b) {
NSDate *firstDate = [(Employee *)a startDate];
NSDate *secondDate = [(Employee *)b startDate];
return [firstDate compare:secondDate];
}];
Apple’s documentation on NSSortDescriptor
Apple’s documentation on NSArray

