PGUp, your code has multiple errors that prevent it from working as is, and it doesn't work for values > 99999. Questionable style too; uses global variables, no indentation and pairs instead of ipairs to iterate over an array. The last line of code has no obvious purpose. It even redefines the global table, making important functions unavailable. Using this code would create more problems than it solves.
Nixola has a point, if you need the KEY rather than the value then note that "pairs" makes the function non-deterministic.
You should use a numeric loop or ipairs so that the function has consistent behavior and returns the same key in the event of duplicates.
Either that or you have to ensure that there are no duplicate minimal values in the table.
Depending on what you are trying to achieve, determinism may or may not be an issue.