Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Re: Sort Array

by ZZamboni (Curate)
on Jun 08, 2001 at 02:02 UTC ( #86777=note: print w/ replies, xml ) Need Help??

in reply to Sort Array

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.


Comment on Re: Sort Array

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://86777]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (9)
As of 2015-11-26 12:24 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (697 votes), past polls