# Getting index and value of the second highest element of CuArray

**URL:** https://discourse.julialang.org/t/getting-index-and-value-of-the-second-highest-element-of-cuarray/80054
**Category:** GPU
**Tags:** question
**Created:** [April 26, 2022, 12:27pm UTC](https://discourse.julialang.org/t/getting-index-and-value-of-the-second-highest-element-of-cuarray/80054 "2022-04-26T12:27:02Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Phuntsho](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/phuntsho/32/46546_2.png) [@Phuntsho](https://discourse.julialang.org/u/Phuntsho)
#### Post date: [April 26, 2022, 12:27pm UTC](https://discourse.julialang.org/t/getting-index-and-value-of-the-second-highest-element-of-cuarray/80054/1 "2022-04-26T12:27:02Z")

</div>

For CuArray, say, A, we can use findmax(A) to find the value and index of the highest element efficiently. Is there a similar function that does for the second element? Thank you in advance for your help.

---

<div class="post-metadata">

### Author: ![maleadt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/maleadt/32/10097_2.png) [@maleadt](https://discourse.julialang.org/u/maleadt)
#### Post date: [April 26, 2022, 3:24pm UTC](https://discourse.julialang.org/t/getting-index-and-value-of-the-second-highest-element-of-cuarray/80054/2 "2022-04-26T15:24:21Z")

</div>

You can try `partialsort!`.
