标签:
NSArray *array = @[@"19",@"7",@"3",@"4",@"5",@"8"];
NSArray *sortedArray = [array sortedArrayUsingComparator: ^(id obj1, id obj2) {
if ([obj1 integerValue] > [obj2 integerValue]) {
return -1L;
}
if ([obj1 integerValue] < [obj2 integerValue]) {
return 1L;
}
return 0L;
}];
NSLog(@"%@",sortedArray);
//使用Seltor来选择比较数组
NSArray *array22 = @[@1,@2,@13,@12,@23];
NSArray *resultArray1 = [array22 sortedArrayUsingSelector:@selector(compare:)];
NSLog(@"%@",resultArray1);
标签:
原文地址:http://www.cnblogs.com/wanghengheng/p/4793251.html