Let's see the code:
NSArray *array = @[@1,@3,@2,@5, @6];
NSArray *array2 = [array sortedArrayUsingComparator:^NSComparisonResult(id _Nonnull obj1, id _Nonnull obj2) {
return NSOrderedSame;
}];
I know the usage of return NSOrderedAscending
and return NSOrderedDescending
. But if I write return NSOrderedSame
in the block, whether the sequence of these two item won't be changed.
If you want to know which sort algorithm is used in NSArray, you can go to this question: What sort function is used in NSArray?
If you return NSOrderedSame in the sort block, the array will do nothing for all algorithms. :)