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

Re: Sorting an array on two computed fields

by davido (Cardinal)
on Dec 16, 2005 at 10:11 UTC ( [id://517196]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    my @sorted = map { 
                   $_->[2] 
    ...
                     map {
                       [ split( /-/, $_ ), $_ ]
                     } @unsorted;
    
  2. or download this
    my @sorted = sort { my @a = split /-/, $a;
                        my @b = split /-/, $b;
                        $a[0] <=> $b[0] or
                        $a[1] <=> $b[1]
                      } @unsorted;
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (4)
As of 2024-03-28 15:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found