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

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

From:
Graham Barr
Date:
June 8, 2004 23:34
Subject:
Re: sort in scalar context, but broken due to inexperience.
Message ID:
D9AF0DE3-B9DE-11D8-9C00-0003937E19DE@pobox.com
On 8 Jun 2004, at 15:59, Nick Ing-Simmons wrote:
> David Nicol <davidnicol@pay2send.com> writes:
>> Attached is a patch to pp_sort.c that adds code to give a sortedness
>> ratio in scalar context.
>
>
> This looks like quite a big change for a return value which we seem
> unable to reach consensus on.

And something that will get little use.

> (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.)

i would rather leave it as-is. If you want min/max use List::Util for 
the simple cases and (sort ...)[0] where you need your own compare sub.

> What can one use your sortedness value for?

Um, yes.

Graham.




nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About