Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Numeric sorting WITHOUT <=>

by GrandFather (Cardinal)
on Oct 10, 2012 at 01:43 UTC ( #998110=note: print w/ replies, xml ) Need Help??


in reply to Numeric sorting WITHOUT <=>

my @sorted = sort {sprintf ('%09d', $a) cmp sprintf ('%09d', $b)} keys + %jetsons;
True laziness is hard work


Comment on Re: Numeric sorting WITHOUT <=>
Download Code
Re^2: Numeric sorting WITHOUT <=>
by dsheroh (Parson) on Oct 10, 2012 at 09:44 UTC
    Don't really need the explicit cmp:

    my @sorted = sort map { sprintf '%09d', $_ } keys %jetsons;

      But that's nearly half the length so it can't be near half so good. :-)

      True laziness is hard work

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (9)
As of 2014-08-23 08:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (172 votes), past polls