in reply to Re^8: Anyone use "xor" in conditionals? (faster)
in thread Anyone use "xor" in conditionals?

which is why i don't send in patches for this type of thing (slow but not broken). the actual fastest i've found is almost the most simple...

use Socket qw( inet_aton inet_ntoa ); sub sort_sock { map { inet_ntoa($_) } sort map { inet_aton($_) } @_ }

which give me:

       s/iter faster    tye   sock
faster   2.06     --   -29%   -64%
tye      1.46    41%     --   -49%
sock    0.737   179%    98%     --

can it get better? will locale settings mess with the sort? will Unicode bite me? i'm unsure.

Replies are listed 'Best First'.
Re^10: [IP Sorting] (was) Anyone use "xor" in conditionals? (faster)
by RMGir (Prior) on Feb 27, 2004 at 12:40 UTC
    ++ zengargoyle!

    Using inet_aton and inet_ntoa for this is very elegant. I'll have to keep that trick in mind.


    Mike