Sorting IP addresses with LogoFE 
Author Message
 Sorting IP addresses with LogoFE

Quote:
> All is good, it works well, however it only sorts to the second place of
> the last octet. For example...

> 192.168.100.118 --- 5 hits
> 192.168.100.119 --- 10 hits
> 192.168.100.12 --- 3 hits
> 192.168.100.120 --- 22 hits

> How do I get the 192.168.100.12 to go where it supposed to (at
> the beginning)?

Importing a text file called "data" with:

soporta "data

I get

show :data
[[192.168.100.118 --- 5 hits]
 [192.168.100.119 --- 10 hits]
 [192.168.100.12 --- 3 hits]
 [192.168.100.120 --- 22 hits]
]

impon is similar to map (it applies a function to
every element of a list, the list "data", for example)

show impon "first :data
[192.168.100.118
 192.168.100.119
 192.168.100.12
 192.168.100.120]

desmarca is "remove marks"

show impon [desmarca: ". first] :data
[[192 168 100 118]
 [192 168 100 119]
 [192 168 100 12]
 [192 168 100 120]]

categoriza outputs indexes to elements of the list used
to produce a sorted list.

show categoriza impon [desmarca: ". first] :data
[2 0 1 3]

The first index is 2, if I take (using "toma" -- take)
the element indexed by 2 from the list I get...

show toma list 2 impon [desmarca: ". first] :data
[192 168 100 12]

which is the first element of the sorted list.

The second index is 0, whose element is the second
in the sorted list:

show toma list 0 impon [desmarca: ". first] :data
[192 168 100 118]

Also:

show toma list 1 impon [desmarca: ". first] :data
[192 168 100 119]
show toma list 3 impon [desmarca: ". first] :data
[192 168 100 120]

Now all of them:

show toma [[2 0 1 3] [192.168.100.118 192.168.100.119 192.168.100.12
192.168.100.120]]
[192.168.100.12
 192.168.100.118
 192.168.100.119
 192.168.100.120]

mismo is "same" (the output is the input)

show mismo :data
[[192.168.100.118 --- 5 hits]
 [192.168.100.119 --- 10 hits]
 [192.168.100.12 --- 3 hits]
 [192.168.100.120 --- 22 hits]]

encaja is used to collect different results into a single list

show encaja [
 [categoriza impon [desmarca: ". first]]
 mismo
] :data

[[2 0 1 3]
 [[192.168.100.118 --- 5 hits]
  [192.168.100.119 --- 10 hits]
  [192.168.100.12 --- 3 hits]
  [192.168.100.120 --- 22 hits]
 ]
]

The list sorted by IP number is:

show toma encaja [
 [categoriza impon [desmarca: ". first]]
 mismo
] :data

[[192.168.100.12 --- 3 hits]
 [192.168.100.118 --- 5 hits]
 [192.168.100.119 --- 10 hits]
 [192.168.100.120 --- 22 hits]]

To sort by number of hits I would use:

show toma encaja [
 [categoriza impon [desmarca: ". item 3]]
 mismo
] :data

[[192.168.100.12 --- 3 hits]
 [192.168.100.118 --- 5 hits]
 [192.168.100.119 --- 10 hits]
 [192.168.100.120 --- 22 hits]]

to sort in reverse order I would use "refleja":

show refleja toma encaja [
 [categoriza impon [desmarca: ". item 3]]
 mismo
] :data

[[192.168.100.120 --- 22 hits]
 [192.168.100.119 --- 10 hits]
 [192.168.100.118 --- 5 hits]
 [192.168.100.12 --- 3 hits]]

Then I could export the data to a file or to the
clipboard with exporta:

exporta "clipboard refleja toma encaja [
 [categoriza impon [desmarca: ". item 3]]
 mismo
] :data

I'll paste the result here:

192.168.100.120 --- 22 hits
192.168.100.119 --- 10 hits
192.168.100.118 --- 5 hits
192.168.100.12 --- 3 hits

Daniel
http://www.*-*-*.com/

To unsubscribe from this group, send an email to:

LogoForum messages are archived at:
http://www.*-*-*.com/

Your use of Yahoo! Groups is subject to http://www.*-*-*.com/



Sat, 26 Jun 2004 14:48:04 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Anyway to get the server ip address not the browser ip address

2. sorting on IP addresses

3. IP address

4. Expand IP address range

5. ip address from ifconfig

6. Extract IP addresses from text file

7. Matching Octet of IP address

8. IP Addresses and Port Numbers

9. Getting the IP Address within RB

10. Reach new site through IP address?

11. Internet connection IP address

12. TCP OPEN ERROR when using IP Address !

 

 
Powered by phpBB® Forum Software