.m文件
NSInteger priceCompare(id obj1, id obj2, void *context) {
float price1 = [[obj1 objectForKey: @"minprice"] floatValue];
float price2 = [[obj2 objectForKey: @"minprice"] floatValue];
if (price1 < price2)
return NSOrderedAscending;
else if (price1 > price2)
return NSOrderedDescending;
else
return NSOrderedSame;
}
.h文 件
NSMutableArray *sortedArray =(NSMutableArray *)[_flightInfoDataSource sortedArrayUsingFunction: priceCompare context: NULL]