freelanceprogrammers.org Forum Index » Perl
New to Perl
Joined: 07 May 2004
Posts: 7
New to Perl
I`m trying to sort some numerical values in ascending order from some
output that I print to screen. Would anyone know how to do this?
Steve
Joined: 05 May 2004
Posts: 16
New to Perl
I guess you mean "from some input source before I use it as output that
I print to screen", right?
Look into getting you numbers into an array variable like @numbers, and
then sorting them with
@sorted = sort { $a <=> $b } @numbers;
`sort` by itself sorts alphabetically, so `35` would be before `7`, so
that is why you need to include the block. Read the documentation on
`sort` (perldoc -f sort) for greater insight into the function and how
to use it in this fashion.
Rex
--- perl_1978 <no_reply@yahoogroups.com> wrote:
> I`m trying to sort some numerical values in ascending order from some
>
> output that I print to screen. Would anyone know how to do this?
>
> Steve
>
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
>
Joined: 08 May 2004
Posts: 1
New to Perl
Use sort function.
raymond raj
--- In perl_official@yahoogroups.com, perl_1978 <no_reply@y...> wrote:
> I`m trying to sort some numerical values in ascending order from
some
> output that I print to screen. Would anyone know how to do this?
>
> Steve
Joined: 07 May 2004
Posts: 7
New to Perl
This sounds familar. I will check the docs and see what it says
about the sort function. Thanks
--- In perl_official@yahoogroups.com, El Rex <rex@b...> wrote:
>
> I guess you mean "from some input source before I use it as output
that
> I print to screen", right?
>
> Look into getting you numbers into an array variable like
@numbers, and
> then sorting them with
>
> @sorted = sort { $a <=> $b } @numbers;
>
> `sort` by itself sorts alphabetically, so `35` would be
before `7`, so
> that is why you need to include the block. Read the documentation
on
> `sort` (perldoc -f sort) for greater insight into the function and
how
> to use it in this fashion.
>
> Rex
>
>
> --- perl_1978 <no_reply@yahoogroups.com> wrote:
> > I`m trying to sort some numerical values in ascending order from
some
> >
> > output that I print to screen. Would anyone know how to do this?
> >
> > Steve
> >
> >
> >
> >
> >
> > Yahoo! Groups Links
> >
> >
> >
> >
> >
All times are GMT
Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Freelace Website Designer - Customer web design and software building.
Booking Calendar - reservation calendar script
Land Surveying - total station instruments and equipments
China Wholesale - Electronics Products
Character Studio - Tutorials and Help
Booking Calendar - reservation calendar script
Land Surveying - total station instruments and equipments
China Wholesale - Electronics Products
Character Studio - Tutorials and Help







