Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Custom "sort" routine

by kyle (Abbot)
on Feb 09, 2009 at 16:06 UTC ( #742471=note: print w/replies, xml ) Need Help??


in reply to Custom "sort" routine

You don't account for $subX at all.

my @list = qw( .coop .com.co .com.mv .com.fj .com.sb .com.nf ); @list= sort { my (undef,$sub1,$tld1)=split /\./,$a; my (undef,$sub2,$tld2)= split /\./,$b; warn "[$sub1].[$tld1] cmp [$sub2].[$tld2]\n"; $sub1 cmp $sub2 || $tld1 cmp $tld2 } @list; print "$_\n" for @list; __END__ .com.co .com.fj .com.mv .com.nf .com.sb .coop

Update: Fixed a couple of problems after reading the comment from moritz.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (11)
As of 2018-10-15 21:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    When I need money for a bigger acquisition, I usually ...














    Results (82 votes). Check out past polls.

    Notices?