从阵列中挑出特定数量? [英] Pick Out Specific Number from Array?

查看:90
本文介绍了从阵列中挑出特定数量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一堆充满数字的NSArray。无论如何,我可以以某种方式获取一个特定的数字,特别是:

I have a bunch of NSArrays filled with numbers. Is there anyway that I can somehow grab a specific number, specifically like:

数组中第三高的数字,或数组中第24个最高的数字?

Third highest number in array, or 24th highest number in array?

但是我不想只是抓住数字,我也需要引用它在数组中的索引,如果可以在这个过程中保留它。

But I don't want to just grab the number, I also need a reference to the index it was in the array as well, if that can be retained in the process.

谢谢。

推荐答案


数组中第三高的数字,或数组中第24个最高的数字?

Third highest number in array, or 24th highest number in array?

创建数组的临时副本并按升序排序。

获取索引的数字 3-1 24-1

Create a temporary copy of the array and sort it ascending.
Get the number at index 3-1 or 24-1.


我还需要引用它在数组中的索引

I also need a reference to the index it was in the array as well

现在使用 indexOfObject: indexOfObjectIdenticalTo:获取实际索引。

Now use indexOfObject: or indexOfObjectIdenticalTo: to get the actual index.

这篇关于从阵列中挑出特定数量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆