字典排序
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[]) {
@autoreleasepool {
NSDictionary *dic=@{@"1-1":@"02",
@"1-2":@"11",
@"1-3":@"89",
@"1-4":@"7"};
NSArray *arr=[dic allValues];
NSLog(@"排序前输出😁");
for (id str in arr) {
NSLog(@"%@",str);
}
// 排序
arr=[arr sortedArrayUsingComparator:^NSComparisonResult(id obj1, id obj2) {
return [obj1 compare:obj2];
}];
NSLog(@"排序后输出😄");
for (id str in arr) {
NSLog(@"%@",str);
}
}
return 0;
}