NSSortDescriptor *descriptor1 = [[NSSortDescriptor alloc] initWithKey:@"lastName" ascending:YES];
NSSortDescriptor *descriptor2 = [[NSSortDescriptor alloc] initWithKey:@"firstName" ascending:YES];
NSArray *sorted = [contatcs sortedArrayUsingDescriptors:@[descriptor1, descriptor2]];
配列内の記述子の順序によって優先度が決まります。コアデータクエリの場合、次のようになります
NSManagedObjectContext *moc = [self managedObjectContext];
NSEntityDescription *entityDescription = [NSEntityDescription entityForName:@"Contact" inManagedObjectContext:moc];
NSFetchRequest *request = [[NSFetchRequest alloc] init];
[request setEntity:entityDescription];
[request setSortDescriptors:@[descriptor1, descriptor2]];
NSError *error;
NSArray *array = [moc executeFetchRequest:request error:&error];
if (array == nil)
{
// Deal with error...
}