http://www.perlmonks.org?node_id=492418


in reply to Re: [ Natural Sort ]: Sorting a string with numbers
in thread [ Natural Sort ]: Sorting a string with numbers

Did you do something wrong? I got what you expected:
#!/your/perl/here use strict; use warnings; my @list = qw(apple1 apple apple20); my @sorted = @list[ map { unpack "N", substr($_,-4) } sort map { my $key = $list[$_]; $key =~ s[(\d+)][ pack "N", $1 ]ge; $key . pack "N", $_ } 0..$#list ]; print "@sorted\n";
gives:
apple apple1 apple20
Post your code and let's check it.

-QM
--
Quantum Mechanics: The dreams stuff is made of