Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^2: Fastest way to sort a list of integers into 0,1,2,3,-3,-2,-1

by ikegami (Patriarch)
on Feb 06, 2019 at 03:31 UTC ( [id://1229451]=note: print w/replies, xml ) Need Help??


in reply to Re: Fastest way to sort a list of integers into 0,1,2,3,-3,-2,-1
in thread Fastest way to sort a list of integers into 0,1,2,3,-3,-2,-1

Isn't
@list = unpack 'j*', pack 'J*', sort { $a <=> $b } unpack 'J*', pack 'j*', @list;
just a complicated/expensive way of doing
@list = unpack 'j>*', sort pack 'j>*', @list;

Replies are listed 'Best First'.
Re^3: Fastest way to sort a list of integers into 0,1,2,3,-3,-2,-1
by vr (Curate) on Feb 06, 2019 at 09:33 UTC

    No, ikegami, what you wrote won't work, but perhaps, instead, you meant Tux' version. It's slower -- (un)packing per element rather than "en masse" into (from) single scalar.

      Oh right. It would be

      @list = map { unpack 'j>', $_ } sort map { pack 'j>', $_ } @list;

      I knew I was tired and missing something.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (10)
As of 2024-03-28 12:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found