farhan has asked for the wisdom of the Perl Monks concerning the following question:
This program is sorting only $val1 not $val2. How I can sort $val1, $val2 together.open(FH,"abc1") or die "not open"; while(<FH>) { my($val1,$val2) = split(/,/,$_); push @record,[$val1,$val2]; } close(FH); my @sorted = sort {$a->[0] <=> $b->[0]} @record; foreach my $rec (@sorted) { print "$rec->[0],$rec->[1]"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Sorting Issue
by GrandFather (Saint) on Jul 27, 2006 at 10:27 UTC | |
| |
|
Re: Sorting Issue
by Velaki (Chaplain) on Jul 27, 2006 at 10:34 UTC | |
by farhan (Novice) on Jul 27, 2006 at 11:36 UTC | |
|
Re: Sorting Issue
by Hue-Bond (Priest) on Jul 27, 2006 at 10:17 UTC | |
|
Re: Sorting Issue
by rodion (Chaplain) on Jul 27, 2006 at 10:23 UTC | |
|
Re: Sorting Issue
by johngg (Canon) on Jul 27, 2006 at 13:49 UTC | |
|
Re: Sorting Issue
by Moron (Curate) on Jul 27, 2006 at 12:30 UTC |