I have a NSMutableArray
.
It contains NSIndexPaths
which itself a NSUInteger array.
Array looks like this
[
(NSIndexPath xxxxxxx) 3 indexes [1, 0, 0],
(NSIndexPath xxxxxxx) 3 indexes [2, 1, 1],
(NSIndexPath xxxxxxx) 3 indexes [1, 1, 0],
(NSIndexPath xxxxxxx) 3 indexes [1, 0, 1],
. .
]
Now i want to sort the NSMutableArray
based on NSIndexPath
integer array values. And the result should be following like this.
[
(NSIndexPath xxxxxxx) 3 indexes [1, 0, 0],
(NSIndexPath xxxxxxx) 3 indexes [1, 0, 1],
(NSIndexPath xxxxxxx) 3 indexes [1, 1, 0],
(NSIndexPath xxxxxxx) 3 indexes [2, 1, 1],
..
]
How to do it?
假设你的NSMutableArray
被称为indexPaths
,你可以这样做:
[indexPaths sortUsingSelector:@selector(compare:)];
除了Maddy的建议,您可以尝试使用应用所需特定排序规则的自定义NSSortDescriptor。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.