Bug #81024 [Opn->Nab]: The uasort / uksort function does not work correctly

From: Date: Sun, 09 May 2021 22:07:04 +0000
Subject: Bug #81024 [Opn->Nab]: The uasort / uksort function does not work correctly
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-233757@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=81024&edit=1 ID: 81024 Updated by: requinix@php.net Reported by: ermolaev-nv at ro dot ru Summary: The uasort / uksort function does not work correctly -Status: Open +Status: Not a bug Type: Bug -Package: *General Issues +Package: Arrays related Operating System: Docker php:8.0.6-cli-alpine3.12 PHP Version: 8.0.6 Block user comment: N Private report: N New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php The callback function must return an integer, not a boolean. Previous Comments: ------------------------------------------------------------------------ [2021-05-09 22:05:48] ermolaev-nv at ro dot ru Description: ------------ The uasort / uksort function does not work correctly Test script: --------------- <?php $ar = [ [393, 464], [-59, 180], [-342, 402], [-90, 135], [-302, 207], ]; uasort($ar, static fn($a, $b) : int => $a[0] > $b[0]); var_dump($ar); Expected result: ---------------- array(5) { [2]=> array(2) { [0]=> int(-342) [1]=> int(402) } [4]=> array(2) { [0]=> int(-302) [1]=> int(207) } [3]=> array(2) { [0]=> int(-90) [1]=> int(135) } [1]=> array(2) { [0]=> int(-59) [1]=> int(180) } [0]=> array(2) { [0]=> int(393) [1]=> int(464) } } Actual result: -------------- array(5) { [1]=> array(2) { [0]=> int(-59) [1]=> int(180) } [2]=> array(2) { [0]=> int(-342) [1]=> int(402) } [4]=> array(2) { [0]=> int(-302) [1]=> int(207) } [3]=> array(2) { [0]=> int(-90) [1]=> int(135) } [0]=> array(2) { [0]=> int(393) [1]=> int(464) } } ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=81024&edit=1

« previous php.bugs (#233757) next »