[LUA Question] sort key based table by value

Hi devs,
i have a problem that i cant solve - googled like crazy :/
i want to sort a key based table by its values. example:
-> print with pairs() would give
http://wowwiki.wikia.com/wiki/API_sort : pairsByKeys does sort only by names
what i want is a sort like this:
atm i convert the table to a another num based table so i can use sort(), but that like cheap workarround
i have a problem that i cant solve - googled like crazy :/
i want to sort a key based table by its values. example:
- Code: Select all
table = {"Name1" = 5, "Name2" = 7, "Name3" = 1}
-> print with pairs() would give
- Code: Select all
Name1 5
Name2 7
Name3 1
http://wowwiki.wikia.com/wiki/API_sort : pairsByKeys does sort only by names
what i want is a sort like this:
- Code: Select all
Name2 7
Name1 5
Name3 1
atm i convert the table to a another num based table so i can use sort(), but that like cheap workarround