Jeff Westman wrote:
> 
> Hello,

Hello,

> I have some data that is pipe-delimited, that I would like to sort
> on the first column (numeric).  The data looks like this:
> 
> 173|Supertramp|The Very Best of Supertramp
> 19|Story, Liz|My Foolish Heart
> 54|Tchaikovsky|Nutcracker Suite
> 187|Tesla|Time's Makin' Changes: The Best of Tesla
> 
> and once sorted, it should look like
> 
> 19|Story, Liz|My Foolish Heart
> 54|Tchaikovsky|Nutcracker Suite
> 173|Supertramp|The Very Best of Supertramp
> 187|Tesla|Time's Makin' Changes: The Best of Tesla
> 
> I tried usint "sort {$a <=> $b}" but got an error:
> 
> Argument "173|Supertramp|The Very Best of Supertramp" isn't numeric
> in sort at med2cdr.pl line 1.
> 
> So I know I have to write my own sort sub-routine, perhaps using
> 'split', but I haven't a clue where or how to write that.
> 
> Any help would be greatly appreciated!

It is not an error, it is a warning, and you can turn it off while you are sorting:

my @sorted = do { no warnings 'numeric'; sort { $a <=> $b } @array };


John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to