Re: com php-src: Faster sorting algo: UPGRADING Zend/Makefile.am Zend/tests/methods-on-non-objects-usort.phpt Zend/zend_API.c Zend/zend_hash.c
Zend/zend_hash.h Zend/zend_ini.c Zend/zend_llist.c Zend/zend_qsort.c Zend/zend_qsort.h Zend/zend_sort.c Zend/zend_sort.h Zend/zend_ts_hash.c
Zend/zend_types.h configure.in ext/ereg/ereg.c ext/intl/collator/collator_sort.c ext/phar/dirstream.c ext/phar/phar_internal.h ext/standard/array.c
ext/standard/info.c ex
| From: | Andrea Faulds | Date: | Mon, 19 Jan 2015 05:07:57 +0000 |
| Subject: | Re: com php-src: Faster sorting algo: UPGRADING Zend/Makefile.am Zend/tests/methods-on-non-objects-usort.phpt Zend/zend_API.c Zend/zend_hash.c Zend/zend_hash.h Zend/zend_ini.c Zend/zend_llist.c Zend/zend_qsort.c Zend/zend_qsort.h Zend/zend_sort.c Zend/zend_sort.h Zend/zend_ts_hash.c Zend/zend_types.h configure.in ext/ereg/ereg.c ext/intl/collator/collator_sort.c ext/phar/dirstream.c ext/phar/phar_internal.h ext/standard/array.c ext/standard/info.c ex |
||
| References: | 1 2 3 4 5 6 7 8 9 10 11 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-80766@lists.php.net to get a copy of this message | ||
> On 19 Jan 2015, at 05:03, Rasmus Lerdorf <rasmus@lerdorf.com> wrote:
>
> On 01/18/2015 09:00 PM, Andrea Faulds wrote:
>> That would also mean a future sorting API could unify user sorts and non-user sorts: just
>> make the default callback be cmp().
>>
>> Usage would be like this:
>>
>> cmp(1, 2); // 1
>> cmp(1, 1); // 0
>> cmp(2, 1); // 1
>>
>> Essentially, exactly like the spaceship in Perl, but a function.
>>
>> Thoughts?
>
> Well, if you really meant that would be the output, perhaps we should
> get someone else to write it. :)
I noticed that erratum the moment after I sent the email. Oh, if only emails could be edited *after*
being sent…
The output would be:
cmp(1, 2); // -1
cmp(1, 1); // 0
cmp(2, 1); // 1
There should’ve been a minus sign on the third one, a typo. But I’d forgotten that comparison
functions actually go the other way round.
I suppose this proves my point that cmp() would make things easier ;)
--
Andrea Faulds
http://ajf.me/