Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: a more efficient lexicographical sort?

by Limbic~Region (Chancellor)
on Jan 18, 2006 at 19:08 UTC ( [id://524040]=note: print w/replies, xml ) Need Help??


in reply to a more efficient lexicographical sort?

Anonymous Monk,
The oid_lex_sort() function uses the Schwartzian Transform. Additionally, it uses regular expressions to eliminate leading periods and converts spaces to '.0' globally. If you know none of your OIDs require those regexes then the following might be better. Benchmarking will say for sure.
my @OID; # defined elsewhere @OID = @OID[ map { unpack "N", substr($_,-4) } sort map { pack('N*', split('\.', $OID[$_])) . pack "N", $_ } 0..$#list ];
It is a straight forward translation to tye's one true sort.
Update: Other improvements likely exist but I don't know what constitutes a lexicographical sort of OIDs.

Cheers - L~R

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (6)
As of 2024-04-19 08:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found