> On Aug 17, 2017, at 6:56 PM, Paul Bennett <paul.w.benn...@gmail.com> wrote: > > Hi, All, > > Quick sanity check, if you please. > > Before I start to trying to merge my perl5 Net::IPAddress::Util into > bradclawsie's perl6 IP::Parse, I want to make sure I'm not being crazy > with the way stringification and cmp are overloaded. > > IP Addresses exist "on the wire" and naturally sort as 128-bit > Network-Order numbers. > > IP Addresses are naturally read & written by humans as strings. > > To accommodate both these things, Net::IPAddress::Util overloads '""' > as stringification and <=> as N128-ification (well, actually the > technobabble is deeper, but that's what it amounts to). > > The tricky bit is the overloading of the cmp operator. > > Since perl5 (and IIRC perl6) uses cmp by default in the sort code > block, my assumption has always been "if people are sorting IP > Addresses they want to sort 'naturally' according to the sensible > semantics", so cmp has been overloaded to do the same thing as <=>. > > Is this indeed DWIM, or is it insane troll logic?
Sounds about right to me. Sort by numeric value, not by the stringification.