Lua sorting tables -


i know nothing lua, able modify script wanted to. i'm having troubles sorting table though.

i've found table utils (convert table string),
here's table:

{{line="(golden aura) challenging owl either brave or stupid.",range="(+16 +21)",message="(golden aura) challenging owl either brave or stupid.",colour="crimson",srt=9,keyword="owl",name="an owl"}, {line="(golden aura) busy squirrel chuckles @ thought of fighting him.",range="(+3 +8)",message="(golden aura) busy squirrel chuckles @ thought of fighting him.",colour="gold",srt=7,keyword="squirrel",name="(golden aura) busy squirrel"}, {line="(red aura) parakeet should fair fight!",range="(-2 +2)",message="(red aura) parakeet should fair fight!",colour="springgreen",srt=5,keyword="parakeet",name="(red aura) parakeet"}, {line="(golden aura) challenging cat either brave or stupid.",range="(+16 +21)",message="(golden aura) challenging cat either brave or stupid.",colour="crimson",srt=9,keyword="cat",name="a cat"}} 

i able add srt key , want sort table that. can kind tell me how that, please?

table.sort( table:t [, function( left, right ):sorting function ] ) 

so, since want sort v.srt, like:

table.sort( t, function( a, b ) return a.srt < b.srt end )  k, v in pairs( t )   print( v.srt, v.name ) end 

which should sort them in ascending order , display them.


Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -