数组排序之 NSOrderedAscending 和 NSOrderedDescending
看源码
/*
These constants are used to indicate how items in a request are ordered, from the first one given in a method invocation or function call to the last (that is, left to right in code).
Given the function:
NSComparisonResult f(int a, int b)
If:
a < b then return NSOrderedAscending. The left operand is smaller than the right operand.
a > b then return NSOrderedDescending. The left operand is greater than the right operand.
a == b then return NSOrderedSame. The operands are equal.
*/
// 注意!! 这里的升序降序指的是 按照 index 升序降序
typedef NS_CLOSED_ENUM(NSInteger, NSComparisonResult) {
NSOrderedAscending = -1L,// 升序排列
NSOrderedSame,// 相等
NSOrderedDescending// 降序排列
};
typedef NSComparisonResult (^NSComparator)(id obj1, id obj2);