Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Sorting issues

by epoptai (Curate)
on May 26, 2001 at 20:59 UTC ( [id://83511]=note: print w/replies, xml ) Need Help??


in reply to Sorting issues

Chomp just before the comparison:
my @sorted = sort{ my $one=substr($a,rindex($a,'|')); my $two=substr($b,rindex($b,'|')); chomp($one,$two); ($one <=> $two) } @database;

Update: I only answered the question of where to put a chomp in that block. See the following replies for a more in-depth analysis of the sorting problem.

--
Check out my Perlmonks Related Scripts like framechat, reputer, and xNN.

Edit: chipmunk 2001-05-26

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2024-04-24 09:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found