iOS-排序,比较
2016-11-09 本文已影响21人
无悔zero
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;//升序
}];