Objective c 对NSArray排序:需要在comparator函数中比较对象的索引 这是NSARSARS排序基础的函数之一: - (NSArray *)sortedArrayUsingFunction:(NSInteger (*)(id, id, void *))comparator context:(void *)context

Objective c 对NSArray排序:需要在comparator函数中比较对象的索引 这是NSARSARS排序基础的函数之一: - (NSArray *)sortedArrayUsingFunction:(NSInteger (*)(id, id, void *))comparator context:(void *)context,objective-c,sorting,nsarray,foundation,Objective C,Sorting,Nsarray,Foundation,我需要一个排序函数,其中在comparator函数中,参数是被比较的两个对象数组中的索引。大概是这样的: - (NSArray *)sortedArrayUsingFunction:(NSInteger (*)(NSInteger, NSInteger, void *))comparator context:(void *)context < >我可以实现一个快速排序,调用这种选择器,但是如果在基金会或核心基金会中有这样的东西,我当然

我需要一个排序函数,其中在comparator函数中,参数是被比较的两个对象数组中的索引。大概是这样的:

- (NSArray *)sortedArrayUsingFunction:(NSInteger (*)(NSInteger, NSInteger, void *))comparator
                              context:(void *)context

< >我可以实现一个快速排序,调用这种选择器,但是如果在基金会或核心基金会中有这样的东西,我当然会喜欢使用它。

为什么你需要索引?为什么不使用您自己的迭代代码?@Eliott您想使用快速排序方式对数组进行排序,还是不考虑方法?