//冒泡排序
- (NSMutableArray *)logArrayFunction:(NSMutableArray *)result{
// NSMutableArray *result = [NSMutableArray arrayWithObjects:@1,@4,@2,@3,@5,nil];
// for (int i = 0; i<result.count-1; i++) {
// for (int j = 0; j<result.count-1-i; j++) {
// NSInteger left = [result[j] integerValue];
// NSInteger right = [result[j+1] integerValue];
// if (left>right) {
// [result exchangeObjectAtIndex:j withObjectAtIndex:j+1];
// }
// }
// }
//
// NSLog(@"最终结果:%@",result);//由小到大
for (int i = 0; i<result.count-1; i++) {
for (int j = 0; j<result.count-1-i; j++) {
NSInteger left = [result[j] integerValue];
NSInteger right = [result[j+1] integerValue];
if (left<right) {
[result exchangeObjectAtIndex:j withObjectAtIndex:j+1];
}
}
}
NSLog(@"最终结果:%@",result);//由大到小
return result;
}