gpt4 book ai didi

ios - 如何对包含 NSIndexPath 整数数组的 NSMutableArray 进行排序?

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:03:07 36 4
gpt4 key购买 nike

我有一个 NSMutableArray

它包含 NSIndexPaths,它本身是一个 NSUInteger 数组。

数组看起来像这样

[

 (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],

..

]

现在我想根据 NSIndexPath 整数数组值对 NSMutableArray 进行排序。结果应该是这样的。

[

(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],

..

]

怎么做?

最佳答案

假设你的 NSMutableArray 被称为 indexPaths,你可以这样做:

[indexPaths sortUsingSelector:@selector(compare:)];

关于ios - 如何对包含 NSIndexPath 整数数组的 NSMutableArray 进行排序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17462783/

36 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com