Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Advanced Sorting - GRT - Guttman Rosler Transform

by eyepopslikeamosquito (Archbishop)
on Aug 25, 2003 at 12:26 UTC ( [id://286354]=note: print w/replies, xml ) Need Help??


in reply to Advanced Sorting - GRT - Guttman Rosler Transform

Your example code:

my @sorted=map { substr($_,4) } sort map { pack("LA*",tr/eE/eE/,$_) } @words;
is not quite correct; the "LA*" should be "NA*". The "L" signifies a native 32-bit unsigned integer yet to guarantee sorting correctness on all architectures you must specify "N", network (big-endian) order.

Replies are listed 'Best First'.
Re: Re: Advanced Sorting - GRT - Guttman Rosler Transform
by demerphq (Chancellor) on Aug 25, 2003 at 14:54 UTC

    Ah, good catch. On my architecture it would sort correctly, but not on all. This is one of the reasons this technique can be a bit tricky, but getting it right can have a nice pay off. Cheers.


    ---
    demerphq

    <Elian> And I do take a kind of perverse pleasure in having an OO assembly language...

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://286354]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (2)
As of 2025-07-12 04:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.