Pathologically Eclectic Rubbish Lister | |
PerlMonks |
Re: Sort Arrayby ZZamboni (Curate) |
on Jun 08, 2001 at 02:02 UTC ( [id://86777]=note: print w/replies, xml ) | Need Help?? |
By default sort uses the cmp operator to compare elements,
which does a string comparison. In ASCII order, "10" comes
before "8", which is why you are getting those results. As
wog pointed out, you have to instruct the <=> operator
to make it compare things as numbers.
--ZZamboni
In Section
Seekers of Perl Wisdom
|
|