NSLog(@"第四题");
NSComparator comp=^(id obj1 ,id obj2){
int age1=[ obj1[@"age"]intValue ];
int age2=[obj2[@"age"]intValue];
if(age1==age2){
return [obj1[@"sex"] compare:obj2[@"sex"]];
}
if(age1<age2){
return NSOrderedAscending;
}else if(age1>age2){
return NSOrderedDescending;
}else{
return NSOrderedSame;
}
};
// NSArray*arrsort2=[newarr3 sortedArrayUsingSelector:@selector(compare:)];
NSSortDescriptor *des1=[[NSSortDescriptor alloc]initWithKey:@"age" ascending:YES ];
NSArray*del1=[NSArray arrayWithObjects:des1, nil];
NSArray*arrsort5=[newarr3 sortedArrayUsingDescriptors:del1];
时间: 2024-12-11 01:55:17