#import <Foundation/Foundation.h>
int main(int argc, const char * argv[]) {
@autoreleasepool {
// 2.@"6",@"34",@"56","78"存入数组,并进行排序降序输出结果
NSArray *arr=@[@"6",@"34",@"56",@"78"];
NSComparator com=^(id obj1,id obj2){
int obj11=[obj1 intValue];
int obj22=[obj2 intValue];
if (obj11==obj22) {
return NSOrderedSame;
}else if (obj11>obj22){
return NSOrderedAscending;
}else{
return NSOrderedDescending;
}
};
NSArray *sortArr=[arr sortedArrayUsingComparator:com];
for(id xin in sortArr){
NSLog(@"%@",xin);
}
//第3题 对以下数据进行首字母升序排序,并输出 一种使用冒泡和数组默认的排序*/
NSArray*arr1=@[@"TimCook",@"JonyIve",@"SteveJobs",@"RobertBrunne",@"PhilipSchiller"];
NSArray *sortArr1=[arr1 sortedArrayUsingSelector:@selector(compare:)];
NSLog(@"%@",sortArr1);
}
return 0;
}