develooper Front page | perl.perl5.porters | Postings from June 2004

Re: sort in scalar context, but broken due to inexperience.

david nicol
June 9, 2004 17:11
Re: sort in scalar context, but broken due to inexperience.
Message ID:

Phooey.  I had thought there was a consensus in favor of the
sortedness thing.

The patch, being mostly cut-and-paste, doesn't add all that much
new code. Thanks for the advice about return convention

The sorting_av flag appears to be part of the sort-in-place feature.

On Tue, 2004-06-08 at 09:59, Nick Ing-Simmons wrote: 
> This looks like quite a big change for a return value which we seem
> unable to reach consensus on. 
> (I would still like sort in scalar context to return min or max value
>  - don't care which because one can change cmp function to get the other.)
> What can one use your sortedness value for?

I'm not too clear on that.  Initial data analysis I suppose.  Who was
asking for the feature?  Let's hear their justification for it.  Archive
search indicates that Merlyn said that is what should happen.

> From: Randal L. Schwartz []
> Jay> Understanding that, now I'm wondering why sort() returns undef in
> Jay> scalar context. Shouldn't sort in scalar context return the
> Jay> number of elements sorted?
> No.  It's not documented that way.  It returns undef now.  Maybe
> in a future Perl it will return "percentage sortedness" if there's
> a fast way to calculate that.

On Wed, 2004-06-09 at 05:23, wrote:
> Dave Mitchell <> wrote:
> :
> :I thought that the concensus (such as it is) in a scalar context was that a
> :concensus couldn't be reached on what it was supposed to return, and that
> :therefore it should be left as is, with the warning?
> That's certainly the consensus that I have reached.

david nicol
 "cat and buttered toast" Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About