NSArray *sortDesc = [NSArray arrayWithObject:[NSSortDescriptor sortDescriptorWithKey:@"conditionCode" ascending:YES]];
NSArray *sortedArr = [responseObject[@"retData"] sortedArrayUsingDescriptors:sortDesc];
for (NSDictionary *dic in sortedArr) {
UserAuthModel *model = [UserAuthModel yy_modelWithDictionary:dic];
[self.authenArr addObject:model];
}
如果同一key相同,可以添加多个属性进行排序,如下:
NSSortDescriptor *typeSort = [NSSortDescriptor sortDescriptorWithKey:@"type" ascending:YES];
NSSortDescriptor *lengthSort = [NSSortDescriptor sortDescriptorWithKey:@"length" ascending:YES];
NSArray *sortArr = [daysArr sortedArrayUsingDescriptors:@[typeSort,lengthSort]];