Store variable ID into another variable

I'm using an evented sorting functions that requires me to to only save the highest value out of several values, but to save the variable ID of the highest value. I haven't seen a way of doing this in VX Ace.

Is there perhaps a script call that can be used, or am I missing something basic?
Please show us screenshots of that event sort function.


It depends on how you identify the highest variable.
I apologize, I am unaware of how to attach a photo. Do I need to upload it to another site and the reference it through the "Image Button"? 
You can upload a picture to image hosting sites such as Imgur then just using bbcode (you have that option above text editor) and paste the link of that picture.
tNmbJXr.png


I also have knowledge or ruby scripting, but not enough to make custom scripts - if that helps at all.

Also thank you for helping me out.
One of the things you can do is store each variable you want into an array using the advanced script command sorting the array then ask for the last value:

Code:
a = []# change n1 and n2 to the values you want#game variables n1 (number 1) through n2 (number 2) get stored in the array called a$game_variables[n1..n2].each {|i|  a << i}a.sort! #sort the array a by value$game_variables[your number here] = a.last #this will equal the highest value
Thank you, I didn't know you could use the .each function in a script call - I figured it would throw me an error.

The main issue I'm having though is being able to save the variable ID number so that I know which variable was the highest, and also be able to iterate through the variables and accessing their individual values.
Try this in the same script call:

n1 and n2 would be the same as the first numbers you want

(n1..n2).each {|i|   if $game_variables == a.last   #then i must be the id of the game variable that has the highest value  end }What this would do is if the variable id equals the last value in the a array (which is the highest value) then i must be the id with the highest value. (you could for instance print i to the console and you would get the id of the variable with value a.last).

The script command can take virtually any ruby argument that you could do in a script (as it uses eval which can make it very unsafe).
Awesome, this is exactly what I need, thank you very much.

I also found a round about way of simulating having the variable ID thus fixing my issue, but your method is much faster and cleaner

Original thread: https://forums.rpgmakerweb.com/threads/store-variable-id-into-another-variable.43242/