[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: table.sort question
- From: "Dietmar Segbert" <didi.segbert@...>
- Date: Wed, 19 Oct 2016 19:07:00 +0000
Hello Listers,
thank for your help. Now it works great.
Regards
Dietmar
> oliver.kroth@nec-i.de schrieb am 19.10.16:
> Hi Dietmar,
> look at the description of table.sort. You may give a function as
> parameter that does the decision how to sort.
> maybe like table.sort( vAdressen, function (a,b) return a.City < b.City
> end )
> --
> Oliver
> Am 19.10.2016 um 18:53 schrieb Dietmar Segbert:
>> Hello,
>>
>> i am new to lua. My Milestone 312 ACE, a Daisy-Player, Mp3-Player,
>> Audiorecorder, from Bones
>> http://www.bones.ch
>>
>> becomes in the next Firmware a lua-interface.
>>
>> I can test the beta of that fw and so i want to program a little
>> adressbook.
>>
>> Now i have a question to table.sort()
>>
>> i have a list
>>
>> local vAdressen = {}
>> local vAdr = {}
>> local vAdr.Name = ""
>> local vAdr.City = ""
>> ...
>>
>> I read the fields for the vAdr from a csv-file and store them in
>>
>> vAdressen[1] = vAdr
>> ...
>> vAdressen[n] = vAdr
>>
>> so that i have all my adress-datasets in vAdressen
>>
>> Now i want to sort the table vAdressen for name odr city or ...
>>
>> If i do
>>
>> print(vAdressen[1].Name]
>>
>> the name of my first dataset will be printed
>>
>> What st the correct syntax for the table.sort() function to sort for name
>> or city?
>>
>> Thanks for your help.
>>
>> Best regards
>>
>> Dietmar Segbert
>>
>>