| Category: | Text Processing |
| Author/Contact Info | Jeff japhy Pinyan |
| Description: | Sorts N IP addresses in O(Nk) time, each and every time. Uses the technique called radix sorting. |
use Socket qw( inet_aton inet_ntoa );
sub IP_radix_sort {
for (my $i = 3; $i >= 0; $i--) {
my @table;
for (@_) {
push @{ $table[unpack "\@$i C", $_] }, $_;
}
@_ = map @$_, @table;
}
return @_;
}
sub IPsort {
map inet_ntoa,
IP_radix_sort
map inet_aton,
@_;
}
|
|
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: IP Address sorting
by japhy (Canon) on Oct 24, 2000 at 03:26 UTC | |
|
Re: IP Address sorting
by tadman (Prior) on Feb 13, 2001 at 08:13 UTC | |
by japhy (Canon) on Feb 13, 2001 at 19:47 UTC |