On Tue, Jun 26, 2001 at 12:21:13PM +0100, Mark Bedish wrote:
> I have a very simple tab delimited file containing text and numbers ,
> just the 2 columns and I would like to sort by ascending numeric. I have
> checked Learning Perl and Prog Perl but cannot get it to work - is that
> because you can only sort by key or am I using the wrong approach
> entirely?
Look again for the magic variables $a and $b.
> my @fields = qw/Text Time/;
> my %ch;
> foreach my $key (sort { $ch{1} cmp $ch{2} } keys %ch ) {
sort { $ch{$a} <=> $ch{$b} }
> print OUT "$key: $ch{$key} \n"; # show key and value
> }
>
> Thanks,
>
> Mark Bedish
--
Paul Johnson - [EMAIL PROTECTED]
http://www.pjcj.net