BOOL result = [a compare:b];
if(result == NSOrderedSame) {
a= b
}else if(result == NSOrderedAscending) {
a<b
else if(result ==NSOrderedDescending) {
a>b
}
[array sortUsingComparator:^NSComparisonResult(id _Nonnull obj1, id _Nonnull obj2) {
BOOL result = [obj1 compare:obj2];
return result == NSOrderedDescending;//升序
}];
网友评论