Re: Make sorting stable

From: Date: Thu, 05 Mar 2020 23:58:21 +0000
Subject: Re: Make sorting stable
References: 1 2 3 4 5  Groups: php.internals 
Request: Send a blank email to internals+get-108880@lists.php.net to get a copy of this message
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

« previous php.internals (#108880) next »