Just use it instead of the first code. I kind of paraphrased the expressions but it should be useable. At the end of it the highest value will be
Array.at(index1)
And the second will be
Array.at(index2)
You’ll want to reset both vars to 0 before running that event.
If there is a tie then then it will still work. Barring any flaw to the idea.
edit:
Actually that won't work right for finding the second highest value in some cases. Do this instead: loop over the array twice. Again you'll want to reset the variables to 0 before running the two loops again.
global number index1=0
global number index2=0
array: for each x
compare: array.curvalue >= array.at(index1)
--- set index1 to array.curX
array: for each x
compare: array.curx != index1
compare: array.curvalue >= array.at(index2)
--- set index2 to array.curX