Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Sort an array of strings based on two fields

by BrowserUk (Pope)
on Mar 14, 2013 at 10:18 UTC ( #1023448=note: print w/replies, xml ) Need Help??


in reply to Sort an array of strings based on two fields

Using the GRT:

print for @a;; xxxxxx.2013-2.yyyyy xxxxxx.2013-11.yyyyy xxxxxx.2013-10.yyyyy xxxxxx.2012-52.yyyyy xxxxxx.2013-3.yyyyy xxxxxx.2012-51.yyyyy xxxxxx.2012-50.yyyyy xxxxxx.2013-1.yyyyy xxxxxx.2013-4.yyyyy @b = map{ unpack 'x[NN]a*', $_ } sort map{ m[(\d{4})-(\d+)]; pack 'NNa*', $1, $2, $_ } @a;; print for @b;; xxxxxx.2012-50.yyyyy xxxxxx.2012-51.yyyyy xxxxxx.2012-52.yyyyy xxxxxx.2013-1.yyyyy xxxxxx.2013-2.yyyyy xxxxxx.2013-3.yyyyy xxxxxx.2013-4.yyyyy xxxxxx.2013-10.yyyyy xxxxxx.2013-11.yyyyy

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1023448]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (5)
As of 2018-01-17 13:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How did you see in the new year?










    Results (200 votes). Check out past polls.

    Notices?