I have a key, value table and want to sort the table on a combination of alphabetic and age.
user\_list={ { id='1', name='John', age=11 }, { id='2', name='Zen', age=4 }, { id='1', name='John', age=3 }, { id='1', name='Av', age=7 }, { id='1', name='Av', age=2 } } local user\_sort=function( user1,user2 ) return user1.name \< user2.name end -- sort users alphabetically: table.sort(user\_list, user\_sort)
Output i want to achieve is:
Av 2
Av 7
John 3
John 11
Zen 4
The Above code sorts them alphabetically , but on every run the ages switch around.
How can i have them listed by name and age same time, without giving different result on each run?
