Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
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 ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11124588]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2024-04-26 07:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found