Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Complex Sort - using varying numbers of parameters

by ariels (Curate)
on Jul 04, 2002 at 12:52 UTC ( #179449=note: print w/ replies, xml ) Need Help??


in reply to Complex Sort - using varying numbers of parameters

Beyond using the Schwartzian transform, you can use the magic of pack to create your sort keys! Keys N, n and C can all work, if your IDs are nonnegative and small enough (0xFFFFFFFF for the first [which will anyway put you in trouble when you try to manipulate them, or 0xFFFF for the second, or a measly 0xFF for the third).

sub make_key { my $x = shift; pack 'N*', @{$x->{Path}}; }
is enough to create keys; you compare these keys with cmp, so you don't need to pass a coderef to sort (yay!).


Comment on Re: Complex Sort - using varying numbers of parameters
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (18)
As of 2015-07-02 13:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (39 votes), past polls