Geometry nodes - Extracting index at maximum value

Hey everyone, I was just wondering if there is a quick way I can extract the index from a list of “positions”. What I mean is I calculate the length of rays from an array of lines generated on a line. And I want to get the index at the maximum length, this should be pretty straight forward but I am really stuck at this step for days.

For example, at this screenshot I need the index 6 or 7 (doesnt matter) because its length is the max.
Any help appreciated.

Here’s the first thing that comes to mind.


Extracting index of the longest edge.

capture_index.blend (858.9 KB)

2 Likes

Thanks a lot!

Since it is the first result that shows for argmax in GN, I’ll share my solution :


(fails if several values are exactly the max :/)

1 Like

Fix for when several values are the max (takes the 1st one)

Only thing that you need to do is to use Sort Elements and take indices of some range of elements in the end of result geometry.