标签:
1 NSMutableArray *arr = [@[@"0",@"3",@"2",@"6",@"5",@"4",@"7",@"1"] mutableCopy]; 2 3 for (int i=0; i<[arr count]-1; i++) { 4 for (int j=0; j<[arr count]-1-i; j++) { 5 NSString *s1 = arr[j]; 6 NSString *s2 = arr[j+1]; 7 8 NSInteger i1 = [s1 integerValue]; 9 NSInteger i2 = [s2 integerValue]; 10 if (i1 > i2) { 11 [arr replaceObjectAtIndex:j withObject:s2]; 12 [arr replaceObjectAtIndex:j+1 withObject:s1]; 13 } 14 } 15 } 16 NSLog(@"排序后的结果:%@", [arr componentsJoinedByString:@","]);
标签:
原文地址:http://www.cnblogs.com/zbblog/p/5519417.html