Finding the Index of a Specific Value in an Array

What are you trying to achieve?

I am using Pixabay’s API to retrieve a JSON array of image results matching a keyword query.
The API returns two fields of particular interest for me, “webformatURL” contains the image URL, and “likes” shows how many likes that image has.
I want to find the array index for the highest value in the “likes” array, so I can use it to retrieve the corresponding image URL (For use with my WP Autoblogger scenario, social media posts etc.)

Steps taken so far

I have already iterated the JSON response, aggregated the required Arrays, and mapped them to variables.
I can locate the highest value of likes using:
‘’’
{{first(sort(12.image-likes; “desc”; “number”))}}
‘’’
But I have no idea of how to determine the array index of this value…

1 Like