sorting subtables

Discuss any general programming issues here
Post Reply
ilbarbax
Posts: 152
Joined: Thu Apr 01, 2010 6:41 pm

sorting subtables

Post by ilbarbax »

Sorry, probably it's my short comprehension, but how can I use the sort command to sort a table by a subtable?

i.e.
t={}
t[0]={name="pippo",age=32}
t[1]={name="pluto",age=24}
t[2]={name="ilBarbax",age=66}

Sort(t.name) does not work
Flinx
Posts: 342
Joined: Sun Feb 14, 2021 9:54 am
Location: Germany

Re: sorting subtables

Post by Flinx »

For this example try

Code: Select all

Sort(t, Function(a, b) Return(a.name < b.name) EndFunction)
Post Reply