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

Re: Sorting an array on two computed fields

by salva (Canon)
on Dec 16, 2005 at 11:25 UTC ( [id://517216]=note: print w/replies, xml ) Need Help??


in reply to Sorting an array on two computed fields

use Sort::Key qw(keysort); my @array = ( '1-1', '2-5', '2', '6', '1-10', '1-3','2-1'); my @sorted = keysort { pack "N*", split /-/, $_ } @array;
update: or with the new Sort::Key::Natural I have just released:
use Sort::Key::Natural 'natsort'; my @sorted = natsort @array;

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2024-04-19 03:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found