0

So currently I have a table in Lua that contains another table (much like a hashtable). It's called email_table, and I have my person_table inside it. The email_table's keys are email_addresses and the person_table holds all information about a person.

Currently what I'm trying to do is sort my email_table based on a value that's inside of person_table. The built in sort function for Lua does not work with such values unfortunately. How would I get started?

Note: tables that contain other tables have nothing to do with hashtables. You keep using that word; I do not think it means what you think it means - Nicol Bolas 2012-04-05 21:49

2

You cannot sort something that isn't an array. If your keys aren't monotonically increasing integers, then you can't sort it. Sorting implies order, and there is no ordering on non-integer keys of tables.

If "The email_table's keys are email_addresses", then `email_table`

cannot be sorted. You can have another table that is a sorted list of email addresses. But this must be a *list*: the keys must be monotonically increasing integer values (1, 2, 3, 4, etc). Those have an explicit order.