Elsa = "Elsa" Anna = "Anna" BestChars = {} BestID = {} Characters = {} Characters[Anna] = 1 Characters[Elsa] = 2 CharList = {"Anna", "Elsa"} ovar = 0 WorstChar = "Default" --Debug to make it not crash Worst = nil --Anna's not bad, but of the list she is the worst. for i = 1, #CharList do if Characters[CharList[i]] >= ovar +1 then --I can't remember if this works ovar = Characters[CharList[i]] table.insert(BestChars, 1, CharListi) table.insert(BestID, 1, Characters[CharList[i]]) Best = CharList[i] elseif Characters[CharList[i]] <= Worst then WorstChar = CharList[i] Worst = Characters[CharList[i]] for c = 1, #BestChars do if Characters[CharID[c]] <= Characters[CharList[i]] then table.insert(BestChars, c, CharList[i]) table.insert(BestID, c, i) end end elseif Worst == nil then Worst = Characters[CharList[i]] WorstChar = CharList[I] for c = 1, #BestChars do if Characters[CharID[c]] <= Characters[CharList[i]] then table.insert(BestChars, c, CharList[i]) table.insert(BestID, c, i) end end end end start = 0 for b =1, #BestChars do if start == 0 then io.write(BestChars[b]) start = 1 else io.write(">"..BestChars[b]) end end