Forum Discussion
Sort variables from highest to lowest
I have done some research, and I think I'm getting nearer to solving this, although it doesn't yet produce outputs into the variables (I get [object Object] for each. Maybe my syntax is out.
var player = GetPlayer();
var Slider1 = player.GetVar("Slider1");
var Slider2 = player.GetVar("Slider2");
var Slider3 = player.GetVar("Slider3");
var Slider4 = player.GetVar("Slider4");
var Slider5 = player.GetVar("Slider5");
var Slider6 = player.GetVar("Slider6");
var Slider7 = player.GetVar("Slider7");
var Slider8 = player.GetVar("Slider8");
var Slider9 = player.GetVar("Slider9");
var Slider10 = player.GetVar("Slider10");
var Slider11 = player.GetVar("Slider11");
var Slider12 = player.GetVar("Slider12");
var Slider13 = player.GetVar("Slider13");
var Slider14 = player.GetVar("Slider14");
var Slider15 = player.GetVar("Slider15");
var Slider16 = player.GetVar("Slider16");
var Slider17 = player.GetVar("Slider17");
var Slider18 = player.GetVar("Slider18");
var SliderName1 = player.GetVar("SliderName_1");
var SliderName2 = player.GetVar("SliderName_2");
var SliderName3 = player.GetVar("SliderName_3");
var SliderName4 = player.GetVar("SliderName_4");
var SliderName5 = player.GetVar("SliderName_5");
var SliderName6 = player.GetVar("SliderName_6");
var SliderName7 = player.GetVar("SliderName_7");
var SliderName8 = player.GetVar("SliderName_8");
var SliderName9 = player.GetVar("SliderName_9");
var SliderName10 = player.GetVar("SliderName_10");
var SliderName11 = player.GetVar("SliderName_11");
var SliderName12 = player.GetVar("SliderName_12");
var SliderName13 = player.GetVar("SliderName_13");
var SliderName14 = player.GetVar("SliderName_14");
var SliderName15 = player.GetVar("SliderName_15");
var SliderName16 = player.GetVar("SliderName_16");
var SliderName17 = player.GetVar("SliderName_17");
var SliderName18 = player.GetVar("SliderName_18");
var myarray = [{ key: SliderName1, val: Slider1 }, { key: SliderName2, val: Slider2 }, { key: SliderName3, val: Slider3 }, { key: SliderName4, val: Slider4 }, { key: SliderName5, val: Slider5 }, { key: SliderName6, val: Slider6 }, { key: SliderName7, val: Slider7 }, { key: SliderName8, val: Slider8 }, { key: SliderName9, val: Slider9 }, { key: SliderName10, val: Slider10 }, { key: SliderName11, val: Slider11 }, { key: SliderName12, val: Slider12 }, { key: SliderName13, val: Slider13 }, { key: SliderName14, val: Slider14 }, { key: SliderName15, val: Slider15 }, { key: SliderName16, val: Slider16 }, { key: SliderName17, val: Slider17 }, { key: SliderName18, val: Slider18}];
myarray.sort(function(a, b){return b.val - a.val});
var [var1, var2, var3, var4, var5, var6, var7, var8, var9, var10, var11, var12, var13, var14, var15, var16, var17, var18] = myarray;
Top31 = var1.toString();
Top32 = var2.toString();
Top33 = var3.toString();
Top3All = myarray.toString();
player.SetVar ("Top3_1" ,Top31);
player.SetVar ("Top3_2" ,Top32);
player.SetVar ("Top3_3" ,Top33);
player.SetVar ("Top3_All", Top3All);