in reply to RFC: Sorting IPv4 addresses
In practice, you often need the IP address in packed form anyway, so there's work reuse. That makes the solutions that pack that much more efficient.
If not, the following would be even faster
unpack_ipv4s( sort { $a <=> $b } pack_ipv4s( @ips ) );
Where unpack_ipv4s and pack_ipv4s are efficient XS functions.
Of course, it would be even faster if you rewrote the sorter to work with numbers directly instead of handling SVs containing numbers.
It's curious that you only used unpack 'N' in combination with split and that you never tried split without unpack 'N'.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: RFC: Sorting IPv4 addresses
by bv (Friar) on Oct 07, 2009 at 01:33 UTC | |
by ikegami (Patriarch) on Oct 07, 2009 at 01:57 UTC | |
by bv (Friar) on Oct 07, 2009 at 14:10 UTC |