Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Re^3: Sorting on different fields

by rchou2 (Novice)
on Jul 23, 2002 at 14:22 UTC ( [id://184423]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Sorting on different fields
in thread Sorting on different fields

right now i'm trying to use this, but it doesn't seem to work..
my @data while (my $line = <TEMPFILE>) { my @elements = $line; push @data, \@elements; # need to store as ref } @data = sort { $$a[2] cmp $$b[2] or $$a[1] <=> $$b[1] } @data or die + "can't sort"; foreach my $item (@data) { print TEMPFILE @$item; print TEMPFILE "\n"; }

Edit by tye

Replies are listed 'Best First'.
Re^5: Sorting on different fields
by Aristotle (Chancellor) on Jul 23, 2002 at 14:32 UTC

    Sidenote: can you please please do us a favour and read Writeup Formatting Tips. Your posts are just about unreadable as is. Specifically, at least learn about the <code> tag.

    Remove the or die "Can't sort". The or forces scalar context on its left operand, which is not what you want.

    Makeshifts last the longest.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2024-04-25 04:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found