项目需求:tableview的cell根据Model中的进度属性进行排序
//排序
NSArray *sortArray = [self.dataSource sortedArrayUsingComparator:^NSComparisonResult(id obj1, id obj2) {
UnitApplyDetailModel *model1 = obj1;
UnitApplyDetailModel *model2 = obj2;
if ([model1.UnitRegCount floatValue]/[model1.UnitAllocate floatValue] > [model2.UnitRegCount floatValue]/[model2.UnitAllocate floatValue]) {
return NSOrderedDescending;//降序
}else if ([model1.UnitRegCount floatValue]/[model1.UnitAllocate floatValue] > [model2.UnitRegCount floatValue]/[model2.UnitAllocate floatValue]){
return NSOrderedAscending;//升序
}else {
return NSOrderedSame;//相等
}
}];