Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Sort problems

by poolpi (Hermit)
on Dec 02, 2008 at 10:45 UTC ( [id://727360]=note: print w/replies, xml ) Need Help??


in reply to Sort problems

#!/usr/bin/perl use strict; use warnings; my @list = qw(a1_2 a1_1 a10_10 a2_10 a2_1 a2_2 a10_1 a10_2 a1_10); my $re = qr/\w(\d+)_(\d+)/; my @sorted = sort { my @A = $a =~ $re; my @B = $b =~ $re; $A[0] <=> $B[0] or $A[1] <=> $B[1]; } @list;

hth,
PooLpi

'Ebry haffa hoe hab im tik a bush'. Jamaican proverb

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2024-04-19 12:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found