razmeth has asked for the wisdom of the Perl Monks concerning the following question:
foreach my $hostname (sort {$hash{$a}->ip_address() cmp $hash{$b}->ip_ +address() or $a cmp $b} keys %hash) {...} sub ip_sort { my @a = split /\./, $a; my @b = split /\./, $b; return $a[0] <=> $b[0] || $a[1] <=> $b[1] || $a[2] <=> $b[2] || $a[3] <=> $b[3]; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Sorting Hash Value Object's IPv4 Address
by johngg (Canon) on Jan 29, 2016 at 12:17 UTC | |
by AnomalousMonk (Archbishop) on Jan 30, 2016 at 17:47 UTC | |
by NetWallah (Canon) on Jan 30, 2016 at 00:47 UTC | |
by johngg (Canon) on Jan 30, 2016 at 12:38 UTC | |
by NetWallah (Canon) on Jan 30, 2016 at 21:22 UTC | |
|
Re: Sorting Hash Value Object's IPv4 Address
by salva (Canon) on Jan 29, 2016 at 08:39 UTC | |
|
Re: Sorting Hash Value Object's IPv4 Address
by NetWallah (Canon) on Jan 29, 2016 at 06:59 UTC |