NSMutableArray 根据key排序
/** * NSMutableArray 排序 * * @param dicArray 数据 * @param key 关键字排序 * @param yesOrNo 升序或降序排列,yes为升序,no为降序 */ - (void) orderArray:(NSMutableArray *)dicArray orderWithKey:(NSString *)key ascending:(BOOL)yesOrNo{ NSSortDescriptor *distanceDescriptor = [[NSSortDescriptor alloc] initWithKey:key ascending:yesOrNo]; NSArray *descriptors = [NSArray arrayWithObjects:distanceDescriptor,nil]; [dicArray sortUsingDescriptors:descriptors]; }