Comparing variables

I need some way to find out what variable has the highest number in it. For example:

I have 3 variables, cow, chicken, and pig. cow = 2, chicken = 1, and pig = 6. I need to find out which one has the highest value. I would just do an if statement comparing the 3 but I plan to have 50+ variables to compare.

Essentially I need to have the app return pig as having the highest variable.

Anyone out there have an idea that could help me? [import]uid: 104852 topic_id: 25675 reply_id: 325675[/import]

math.max?

It can accept any number of parameters. [import]uid: 64174 topic_id: 25675 reply_id: 103798[/import]

math.max returns the highest value of the given parameters.

I’d suggest you throw your variables into a table, do a table.sort and check the last index of that table to get the variable with the highest value…

-finefin [import]uid: 70635 topic_id: 25675 reply_id: 103839[/import]