Whose turn is it? Help for my Custom Battle System

So I'm making a custom turn-based battle system where characters and enemies move around a 17X13 map to atack. (similar to Lunar 1&2) Characters/enemies will have a limited range to move to make Physical attacks and Magical attacks will cover different areas. There may be up to 5 Heros and 8 Enemies in 1 battle. Turns will be taken one at a time in order of agility.(Similar to FFX) This will allow you see where enemies are before you choose your attack.


My Problem


Note-I'm only using events. When battle starts a random troop is selected and it places Heros & Enemies (Events) where they should be. Then it has branches for actions of each character with labels to separate them.


Right now I'm trying to make the turn order.  I need to check everyones agility and put the highest as number 1, second as #2, and so on. I have called everyone's Agi to different variables, but how can I use that to choose whose turn it is/ which label to jump to? 
the Js command "Math.max([value1[, value2[, ...]]])" returns the highest number of a list. So what you could do is....


var numList = $dataSystem.variables(x,x,x,x) //////Put you var numbers here, remember to put with the 00s in place. so exactly as they appear
return Math.max(numList);


This, should, output as the script the highest variable in the list....should.....

Original thread: https://forums.rpgmakerweb.com/threads/whose-turn-is-it-help-for-my-custom-battle-system.56739/