先研究一种方法
NSMutableArray *array = [[NSMutableArray alloc] initWithCapacity:0]; for (int i = 0; i < 10; i++) { int a = arc4random()%100; [array addObject:@(a)]; } NSArray *sortedArray = [array sortedArrayUsingComparator:^NSComparisonResult(NSNumber *obj1,NSNumber *obj2) { if ([obj1 intValue] > [obj2 intValue]) { return NSOrderedDescending; } return (NSComparisonResult)NSOrderedAscending; }]; NSLog(@"%@", sortedArray);