Here are some table functions which I think that they are really usefull.
table.getIndexOfLowest = function(table)
local lowest, r = table[#table], {}
for var = #table,1, -1 do
if table[var] == lowest then
table.insert(r,var)
lowest = table[var]
elseif table[var] < lowest then
for...