in reply to Re: RFC: Sorting IPv4 addresses
in thread RFC: Sorting IPv4 addresses

The packing and XS things are good points. My intended audience was the more casual user who would be uncomfortable implementing anything in XS (I'm only just barely dabbling in Inline::C, myself).

As for split without unpack, I thought that was covered in the splitwise case, which I unabashedly stole from Understanding transformation sorts (ST, GRT), the details. Did you mean something else?

print pack("A25",pack("V*",map{1919242272+$_}(34481450,-49737472,6228,0,-285028276,6979,-1380265972)))

Replies are listed 'Best First'.
Re^3: RFC: Sorting IPv4 addresses
by ikegami (Patriarch) on Oct 07, 2009 at 01:57 UTC

    As for split without unpack, I thought that was covered in the splitwise case

    No, that one doesn't pack

      Ah, I see. That was another case of grabbing code from another node without checking enough. This code runs (by my benchmark) 33% faster than the old split_int:

      #... split_pack => sub { my @sorted = map { join '.', unpack("CCCC", $_) } sort { $a cmp $b } map { pack("CCCC",split /\./) } @ips; }, #...
      print pack("A25",pack("V*",map{1919242272+$_}(34481450,-49737472,6228,0,-285028276,6979,-1380265972)))