Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^2: Rosetta Code: Long List is Long (Updated Solutions)

by Tux (Canon)
on Dec 05, 2022 at 15:33 UTC ( [id://11148568]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    my @sorted = sort               @unsorted;
    my @sorted = sort { $a <=> $b } @unsorted;
    my @sorted = sort { $a cmp $b } @unsorted;
    
  2. or download this
    my @sorted = sort { $a->{id} <=> $b->{id} || $a->{foo} cmp $b->{foo} }
    + @unsorted; # SLOW
    my @sorted = map { $_->[1] } sort { $a->[0] cmp $b->[0] } map { pack "
    +l>A*", $_->{id}, $_->{foo} } @unsorted; # FAST
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (3)
As of 2024-04-20 01:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found