The "how" has been sorted by others, but no explicit mention of "why". Perl's sort comes in a number of different forms. The short form of sort is essentially the same as sort {$a cpm $b} .... cmp (see perlop for cmp and <=>) compares strings so things that look like numbers are sorted like strings. To sort numerically you need the numeric comparison operator <=>. Sort then looks like sort {$a <=> $b} ....
In reply to Re: How can I sort my array numerically on part of the string?
by GrandFather
in thread How can I sort my array numerically on part of the string?
by misterperl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |