in reply to How to sort IP addresses

I was actually here to look for some IPV6 sorting code, but reading various IPV4 sorting solutions made me want to add mine from 10 years ago (when I retired). I've forgotten much, but I remember back then being proud of my fairly simple and fast sort of IP addresses. I may have been deluding myself. I hope not, but I'm prepared if so.

#!/usr/bin/env perl chomp(@IPs = <DATA>); @Sorted = map { substr($_, 4) } sort map { pack('C*', split(/\./, $_) ) . $_ } @IPs; print join("\n", @Sorted) . "\n"; __DATA__ 12.345.111.3 12.345.111.26 61.8.47.111 12.345.111.24 203.134.35.27 12.345.111.5 12.345.111.4