// 数组排序
NSArray *sortResultArray = [buttonsModelArray sortedArrayUsingComparator:^NSComparisonResult(id _Nonnull obj1, id _Nonnull obj2) {
LessonButtonsModel * model1 = [[LessonButtonsModel alloc] initWithDictionary:obj1 error:nil];
LessonButtonsModel * model2 = [[LessonButtonsModel alloc] initWithDictionary:obj2 error:nil];
if ([model1.sort_order intValue] > [model2.sort_order intValue]) {
return NSOrderedDescending;
} else if ([model2.sort_order intValue] > [model1.sort_order intValue]) {
return NSOrderedAscending;
} else
return NSOrderedAscending;
// 升序
}];
网友评论