源自:
http://www.reibang.com/p/84804196972d
NSArray *array = @[@1,@2,@3,@1,@2,@5,@4];
NSArray *testArr = [array sortedArrayWithOptions:NSSortStable usingComparator:
^NSComparisonResult(id _Nonnull obj1, id _Nonnull obj2) {
int value1 = [obj1 intValue];
int value2 = [obj2 intValue];
if (value1 > value2) {
return NSOrderedDescending;
}else if (value1 == value2){
return NSOrderedSame;
}else{
return NSOrderedAscending;
}
}];
這樣排序可以排序任何內(nèi)容, 只要比出大小就可以