SFBankListItemModel为数组中的对象,以该对象中的某个属性进行排序
//对数据按次数排序 降序
NSArray *sortArrays = [userCards sortedArrayUsingComparator:^NSComparisonResult(id obj1, id obj2) {
SFBankListItemModel *model1 = (SFBankListItemModel *)obj1;
SFBankListItemModel *model2 = (SFBankListItemModel *)obj2;
NSNumber *num1 = [NSNumber numberWithUnsignedLongLong:[model1.cardInfo.createTime longLongValue]];
NSNumber *num2 = [NSNumber numberWithUnsignedLongLong:[model2.cardInfo.createTime longLongValue]];
return [num2 compare:num1];
}];
[num2 compare:num1]降序,
[num2 compare:num1]升序
网友评论