Reputation: 153
I have a big array and I want to sort all the elements of the array in alphabetical order.
In a previous subroutine, the element of the array are being pushed to tc_reg array.
I have an array named @tc_lane. When I print element of the array it would look something like this
tx0_abc
rx0_fgw
ref_ghv
..
Now I want to sort this array like this,
ref_ghv
rx0_fgw
tx_abc
..
Upvotes: 3
Views: 5721
Reputation: 385590
If you want
rx0_fgw
rx10_fgw
rx2_fgw
use
my @sorted = sort @unsorted;
If you want
rx0_fgw
rx2_fgw
rx10_fgw
use
use Sort::Key::Natural qw( natsort );
my @sorted = natsort @unsorted;
Upvotes: 8