Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:70242 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 54748 invoked from network); 20 Nov 2013 19:02:47 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Nov 2013 19:02:47 -0000 Authentication-Results: pb1.pair.com header.from=smalyshev@sugarcrm.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=smalyshev@sugarcrm.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain sugarcrm.com designates 108.166.43.75 as permitted sender) X-PHP-List-Original-Sender: smalyshev@sugarcrm.com X-Host-Fingerprint: 108.166.43.75 smtp75.ord1c.emailsrvr.com Linux 2.6 Received: from [108.166.43.75] ([108.166.43.75:48047] helo=smtp75.ord1c.emailsrvr.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 83/10-51208-3570D825 for ; Wed, 20 Nov 2013 14:02:46 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp2.relay.ord1c.emailsrvr.com (SMTP Server) with ESMTP id A90681E80F1; Wed, 20 Nov 2013 14:02:40 -0500 (EST) X-Virus-Scanned: OK Received: by smtp2.relay.ord1c.emailsrvr.com (Authenticated sender: smalyshev-AT-sugarcrm.com) with ESMTPSA id 4735B1E8147; Wed, 20 Nov 2013 14:02:40 -0500 (EST) Message-ID: <528D074F.5010206@sugarcrm.com> Date: Wed, 20 Nov 2013 11:02:39 -0800 Organization: SugarCRM User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:24.0) Gecko/20100101 Thunderbird/24.1.0 MIME-Version: 1.0 To: Nikita Nefedov , "internals@lists.php.net" References: In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Re: array_unique optional compare-callback proposal From: smalyshev@sugarcrm.com (Stas Malyshev) 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