http://www.perlmonks.org?node_id=597519


in reply to Re^2: How to sort IP addresses
in thread How to sort IP addresses

Hm, golfing with GRT? No idea how, but anyway, here's a possible starting point:
$ perl -le '$,=$/; print @ARGV[ map { unpack N, substr $_, -4 } \ sort map { eval("v$ARGV[$_]") . pack N, $_ } 0 .. $#ARGV ]' \ 1.2.1.1 1.1.1.1 1.11.1.1 1.1.1.66 1.1.1.9 1.1.1.1 1.1.1.9 1.1.1.66 1.2.1.1 1.11.1.1
OTOH, that previous version could easily be golfed (ok, just a little) by dropping the initial map (which is useful only when using this snippet "for real" - you know, using sprintf and returning a list):
$ perl -e 'printf "%vd\n", $_ for sort map { eval "v$_" } @ARGV' \ 1.2.1.1 1.1.1.1 1.11.1.1 1.1.1.66 1.1.1.9 1.1.1.1 1.1.1.9 1.1.1.66 1.2.1.1 1.11.1.1
--
AltBlue.