Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: How can I sort my array numerically on part of the string?

by perlfan (Vicar)
on Dec 03, 2020 at 18:00 UTC ( #11124588=note: print w/replies, xml ) Need Help??


in reply to How can I sort my array numerically on part of the string?

You're one line away from the standard hash sorting idioms:
use strict; use warnings; use Data::Dumper (); my @list = ( '1,cat', '2,dog', '22,mouse', '11,eel', '001,elk', '13,mi +nk'); my %list = map { split /,/,$_ } @list; #<-- dis print Data::Dumper::Dumper(\%list);

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (2)
As of 2021-04-13 02:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?