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];
}

 

posted @ 2015-04-02 12:12  wb145230  阅读(160)  评论(0编辑  收藏  举报