#define NSLog(FORMAT, ...) printf("%s\n", [[NSString stringWithFormat:FORMAT, ##__VA_ARGS__] UTF8String])
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[]) {
@autoreleasepool {
NSArray *aa=@[@{@"name":@"陈丰",@"age":@"32"},
@{@"name":@"孙明",@"age":@"24"},
@{@"name":@"王明",@"age":@"12"},
@{@"name":@"李西",@"age":@"50"}
];
NSMutableArray *aa1=[[NSMutableArray alloc]initWithArray:aa];
NSSortDescriptor *bb=[NSSortDescriptor sortDescriptorWithKey:@"name" ascending:1 selector:@selector(localizedCompare:)];
NSArray *bb1=[aa1 sortedArrayUsingDescriptors:[NSArray arrayWithObjects:bb, nil]];
for(int i=0;i<[bb1 count];i++)
{
NSDictionary *bb2=bb1[i];
NSLog(@"名字:%@ 年龄:%@",bb2[@"name"],bb2[@"age"]);
}
}
return 0;
}