Split the network and netmask into separate terms and sort on netmask within network.
knoppix@Microknoppix:~$ perl -MSocket -Mstrict -wE ' my @networks = qw{ 10.182.8.0/26 10.182.8.0/21 10.182.8.64/26 10.182.8.128/26 10.182.8.192/26 }; say for map { $_->[ 0 ] } sort { $a->[ 1 ] cmp $b->[ 1 ] || $a->[ 2 ] <=> $b->[ 2 ] } map { my( $network, $netmask ) = split m{/}; [ $_, inet_aton( $network ), $netmask ]; } @networks;' 10.182.8.0/21 10.182.8.0/26 10.182.8.64/26 10.182.8.128/26 10.182.8.192/26 knoppix@Microknoppix:~$
I hope this is helpful.
Cheers,
JohnGG
In reply to Re^3: Sorting Hash / Array
by johngg
in thread Sorting Hash / Array
by nickt9999
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |