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

Re^3: Sorting Numbers & Text

by johngg (Abbot)
on Jul 12, 2012 at 22:10 UTC ( #981514=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Sorting Numbers & Text
in thread Sorting Numbers & Text

It seems that the warnings are due to a precedence problem that can be fixed with parentheses,

knoppix@Microknoppix:~$ perl -Mstrict -Mwarnings -E ' > my @values = qw{ > 041351920234 > Rabbit > 0343120 > 041271024500 > 0430870 > Apple > 041460301399 > }; > > say for > map { $_->[ 0 ] } > sort { > ( $a->[ 1 ] <=> $b->[ 1 ] ) > || > ( > $a->[ 1 ] > ? $a->[ 0 ] <=> $b->[ 0 ] > : $a->[ 0 ] cmp $b->[ 0 ] > ) > } > map { [ $_, m{^\d} ? 1 : 0 ] } > @values;' Apple Rabbit 0343120 0430870 041271024500 041351920234 041460301399 knoppix@Microknoppix:~$

Thanks for pointing it out.

Cheers,

JohnGG


Comment on Re^3: Sorting Numbers & Text
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (20)
As of 2015-07-28 14:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (256 votes), past polls