iOS 数组排序
NSArray *sortedArray = [userArr sortedArrayUsingComparator:^NSComparisonResult(id obj1, id obj2) { if([VShowUtil isEmptyString:[obj1 objectForKey:@"vlevel"]]) { return NSOrderedDescending; } if([VShowUtil isEmptyString:[obj2 objectForKey:@"vlevel"]]) { return NSOrderedSame; } if ([[obj1 objectForKey:@"vlevel"] intValue] > [[obj2 objectForKey:@"vlevel"] intValue]){ return NSOrderedSame; } if ([[obj1 objectForKey:@"vlevel"] intValue] < [[obj2 objectForKey:@"vlevel"] intValue]){ return NSOrderedDescending; } return NSOrderedSame; }]; [userArr removeAllObjects]; [userArr addObjectsFromArray:sortedArray];
/*! * @Author Yunis_song, 14-12-22 15:12:38 * * @brief 对付费道具进行价格排序 * * @param userArr 付费道具数组 */ - (void)shortArr:(NSMutableArray *)userArr { NSArray *sortDescriptors = [NSArray arrayWithObject:[NSSortDescriptor sortDescriptorWithKey:@"price" ascending:YES]]; [userArr sortUsingDescriptors:sortDescriptors]; }
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。