For example. i have a table
t = {Variant1 = 33, Variant2 = 1, Variant3 = 123, Variant4 = 33}
I need to find the key(s) with highest value(s). So, how can i compare it?
This is how I always do it.
01 | local highest = 0 |
02 | local t = { Variant 1 = 33 , Variant 2 = 1 , Variant 3 = 123 , Variant 4 = 33 } |
03 |
04 | for i,v in pairs (t) do |
05 | if v > highest then |
06 | highest = v |
07 | end |
08 | end |
09 |
10 | print (highest) |
This is the most(maybe) solution I can found:
1 | local t = { 1 , 2 , 3 } |
2 |
3 | print (math.max( unpack (t))) |
About the randomize, why you need to randomize it when it already the same?