Bug #70770 [Ana->Nab]: Natsort: different results for PHP5 and PHP7

From: Date: Fri, 23 Oct 2015 03:21:50 +0000
Subject: Bug #70770 [Ana->Nab]: Natsort: different results for PHP5 and PHP7
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-196758@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=70770&edit=1 ID: 70770 Updated by: laruence@php.net Reported by: tronsha at gmx dot de Summary: Natsort: different results for PHP5 and PHP7 -Status: Analyzed +Status: Not a bug Type: Bug Package: *General Issues PHP Version: 7.0Git-2015-10-22 (Git) Block user comment: N Private report: N New Comment: yes, we are using stable sorting algo in some cases now, so this is a expected behavior. Previous Comments: ------------------------------------------------------------------------ [2015-10-22 16:01:36] rasmus@php.net This is likely because 09 and 009 are actually equivalent in a natural sort and the backend sorting algorithm has changed and the order of equivalent elements don't always match the old algorithm. Both outputs are correct there as far as I am concerned. ------------------------------------------------------------------------ [2015-10-22 13:41:54] tronsha at gmx dot de Description: ------------ --- From manual page: http://www.php.net/function.natsort --- I get different results for PHP5 and PHP7 PHP 5 Array ( [5] => 0 [1] => 8 [3] => 009 [0] => 09 [2] => 10 [4] => 011 ) PHP 7 (dev) Array ( [5] => 0 [1] => 8 [0] => 09 [3] => 009 [2] => 10 [4] => 011 ) Test script: --------------- <?php $zeros = array('09', '8', '10', '009', '011', '0'); natsort($zeros); print_r($zeros); Expected result: ---------------- Array ( [5] => 0 [1] => 8 [3] => 009 [0] => 09 [2] => 10 [4] => 011 ) Actual result: -------------- Array ( [5] => 0 [1] => 8 [0] => 09 [3] => 009 [2] => 10 [4] => 011 ) ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=70770&edit=1

« previous php.bugs (#196758) next »