iOS-排序,比较


BOOL result = [a compare:b];

if(result == NSOrderedSame) {

a= b

}else if(result == NSOrderedAscending) {

a

else if(result ==NSOrderedDescending) {

a>b

}

[array sortUsingComparator:^NSComparisonResult(id  _Nonnull obj1, id  _Nonnull obj2) {

BOOL result =  [obj1 compare:obj2];

return result == NSOrderedDescending;//升序

}];

你可能感兴趣的:(iOS-排序,比较)