Re: Re: array_unique optional compare-callback proposal
Hi!
>> $newArray = array_unique($a, SORT_USERDEFINED, function ($a, $b) {
>> return $a->getWrappedObject()->getIdentity() -
>> $b->getWrappedObject()->getIdentity();
>> });
>>
>>
>> Actually my problem was a little different but you get the idea... And I
>> think there will be even more usecases for this.
What I notice here is that if we add SORT_USERDEFINED, we need to add it
to all other sorts, otherwise it would be inconsistent - why SORT_*
works for all sort functions but SORT_USERDEFINED works only for one of
them? And that opens a bit of a can of worms because for many array
functions this already exists as u* aliases - usort, array_udiff, etc.
--
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
(408)454-6900 ext. 227
Thread (4 messages)