Mehdi has asked for the wisdom of the Perl Monks concerning the following question:
when I use sort() to sort an array like this:
@array = (70, 10, 8);
@array = sort (@array);
the result is : 10, 70, 8
how can I get the result as: 8, 10, 70 in Perl?
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.