Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^5: sorting an array

by moritz (Cardinal)
on Jul 10, 2009 at 11:26 UTC ( [id://778895]=note: print w/replies, xml ) Need Help??


in reply to Re^4: sorting an array
in thread sorting an array

Because it sorts by string comparison. If you have a string $a, and another string which is $b = $a . $any_other_string, than the shorter string $a will always sort lexicographic before the longer string.

If you look into a phone book, you expect Strauss to come before Strausse, so that's what you usually want.

The only case where this doesn't do what you mean is to when you compare numbers of different length. That's what Perl offers the <=> operator for.

Replies are listed 'Best First'.
Re^6: sorting an array
by hnd (Scribe) on Jul 10, 2009 at 11:41 UTC
    thnx again...... i will never forget this again....
    =====================================================
    i'am worst at what do best and for this gift i fell blessed...
    i found it hard it's hard to find well whatever
    NEVERMIND

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2024-04-19 07:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found