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


in reply to array bug?

This isn't a bug, it's a feature.

What's happening is that the numbers are getting sorted as strings, and since 8 comes after 30 (chr(8) > chr(3)) (ord(8) > ord(3)), you get those unwanted effects.

Fortunately, (hurrah!) you can pass additional sorting methods to sort. For instance, reverse sort @arr can be rewritten as sort {$b cmp $a} @arr. You can use the same feature to sort numerically using the UFO operator: sort {$a <=> $b} @arr

There's other ways sort simplifies your life; RTFM for more info.

Update: Successfully picked; thanks, ChemBoy... although what I wrote is technically true as well... :o)


LAI
:eof