Shlomi Fish wrote:
"Wagner, David --- Sr Programmer Analyst --- CFS"
wrote:
Since a \n is at end, then could use split like:
for my $dtl ( sort {$a<=> $b} split(/\n/, $a_string) ) {
One can also do split(/^/m, $a_string) to split into lines while preserving the
newlines.
It wi
Hi,
On Tue, 16 Aug 2011 11:09:35 -0500
"Wagner, David --- Sr Programmer Analyst --- CFS"
wrote:
> >-Original Message-
> >From: Matt [mailto:lm7...@gmail.com]
> >Sent: Tuesday, August 16, 2011 10:04
> >To: beginners@perl.org
> >Subject: Sorting a String
> >
> >I believe you can sort an ar
>-Original Message-
>From: Matt [mailto:lm7...@gmail.com]
>Sent: Tuesday, August 16, 2011 10:04
>To: beginners@perl.org
>Subject: Sorting a String
>
>I believe you can sort an array like so:
>
>sort @my_array;
>
>I need to sort a string though.
>
>I have $a_string that contains:
>
>4565 lin
Matt wrote:
I believe you can sort an array like so:
sort @my_array;
That should be:
@my_array = sort @my_array;
I need to sort a string though.
I have $a_string that contains:
4565 line1
2345 line2
500 line3
etc.
Obviously \n is at end of every line in the string. I need it sorted.
On Tue, Aug 16, 2011 at 12:04 PM, Matt wrote:
> I believe you can sort an array like so:
>
> sort @my_array;
>
> I need to sort a string though.
>
> I have $a_string that contains:
>
> 4565 line1
> 2345 line2
> 500 line3
> etc.
>
> Obviously \n is at end of every line in the string. I need it sor
sort like string or like numbers?
On Tue, Aug 16, 2011 at 18:04, Matt wrote:
> I believe you can sort an array like so:
>
> sort @my_array;
>
> I need to sort a string though.
>
> I have $a_string that contains:
>
> 4565 line1
> 2345 line2
> 500 line3
> etc.
>
> Obviously \n is at end of every li