Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:108880 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 37709 invoked from network); 6 Mar 2020 01:38:34 -0000 Received: from unknown (HELO localhost.localdomain) (76.75.200.58) by pb1.pair.com with SMTP; 6 Mar 2020 01:38:34 -0000 To: internals@lists.php.net References: Date: Fri, 6 Mar 2020 00:58:21 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:52.0) Gecko/20100101 Firefox/52.0 SeaMonkey/2.49.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Posted-By: 46.59.72.204 Subject: Re: [PHP-DEV] Make sorting stable From: ajf@ajf.me (Andrea Faulds) Message-ID: Hi, Nikita Popov wrote: > > I've implemented this variant now. If the comparison function returns a > boolean, you get > >> Deprecated: usort(): Returning bool from comparison function is > deprecated, return one of -1, 0 or 1 instead in %s on line %d > > once per usort() call, and we retry with swapped operands to ensure > compatibility. > > Regards, > Nikita > I think that message could be a little misleading, because any negative or positive value is valid, not just those of magnitude 1, right? IIRC strcmp($a, $b) doesn't just return -1 and 1, and of course this is also the case for the classic ($a - $b). Thanks, Andrea