How do I sort this sort of table...
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

How do I sort this sort of table...

Started by NightLitch, 10 December, 2003, 22:44:26

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

NightLitch

Accociative I think... (can't spell)

How do I sort it...


for vRANGE,vNET in Table do
	local _,_,RANGE1,RANGE2 = strfind(vRANGE, "(%S+)-(%S+)")
		curUser:sendmessage(BOTNAME," Range: "..RANGE1.." - "..RANGE2.."\t\tNetwork: "..vNET)
	end

plz help me...

/NL
//NL

plop

not 2 sure but this might work.
local temp = {}
for vRANGE,vNET in Table do
   tinsert(temp, vRANGE)
end
sort(temp)
for i=1,getn(temp) do 
	local _,_,RANGE1,RANGE2 = strfind(temp[i], "(%S+)-(%S+)")
	curUser:sendmessage(BOTNAME," Range: "..RANGE1.." - "..RANGE2.."\t\tNetwork: "..Table[temp[i]])
end

plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

c h i l l a

#2
nightlitch... it depends if you have IP s to sort then you will need to use the sort func of the logger.
if you sort it with LUA sort function...  tings could get mixed up  like  230.0.0.0  above 32.0.0.0  but if you sort it by name then plops idea is the one, in any case you will need to first creat a non associative table  like plop did.

tinsert(temp,value)

the sort func of the logger,  computes the IP and compares it with the next one

ends up something like this

sort(table, function(a,b) return(Compute(a) < Compute(b)) end)

you need the the compute function.

SMF spam blocked by CleanTalk