On Tuesday, May 28, 2002, at 01:03 , Eric Wang wrote:
[..]
> I have this flat text file with numbers in it.
> I tried to use the sort routine but it seems like the numbers were not
> sorted at all.
a) how did you get the 'numbers' out of the file?
b) what was the specific syntax you used to get
On Tue, May 28, 2002 at 01:20:48PM -0700, Eric Wang wrote:
> @result = sort @array
>
> it sorts the numbers by digits, but not the whole number
> for example is bigger than 443322341 because it's first digit is a 6
Your question was answered by a another poster.
I'll reiterate:
see perldo
use
@result = sort {$a <=> $b} @array;
sort sort's by cmp (string comparison) by default.
> -Original Message-
> From: Eric Wang [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, May 28, 2002 4:21 PM
> To: Timothy Johnson
> Cc: [EMAIL PROTECTED]
> Subject: RE:
the list is like this
664435
3422451
443262
3345223
and if I load this in an array @array
and sort it
@result = sort @array
it sorts the numbers by digits, but not the whole number
for example is bigger than 443322341 because it's first digit is a 6
Help~
Eric
On Tue, 28 May 2002, Timot
On Tue, May 28, 2002 at 01:03:01PM -0700, Eric Wang wrote:
> I have this flat text file with numbers in it.
> I tried to use the sort routine but it seems like the numbers were not
> sorted at all.
Um, we're going to need a little more detail. What was in the file? What
code did you use to read
Maybe you could give us an example of what you've done?
-Original Message-
From: Eric Wang [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, May 28, 2002 1:03 PM
To: [EMAIL PROTECTED]
Subject: the sort routine
Hi People,
I have this flat text file with numbers in it.
I tried to use the sort
perldoc -f sort
sort sort's by cmp by default...
for numerical use
sort { $a <=> $b }
> -Original Message-
> From: Eric Wang [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, May 28, 2002 4:03 PM
> To: [EMAIL PROTECTED]
> Subject: the sort routine
>
>
>
> Hi People,
>
> I have this flat