#40334 [Bgs->Opn]: natsort() does not work for some numbers...

From: Date: Sat, 03 Feb 2007 01:05:59 +0000
Subject: #40334 [Bgs->Opn]: natsort() does not work for some numbers...
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-108363@lists.php.net to get a copy of this message
ID: 40334 User updated by: den4b at mail dot ru Reported By: den4b at mail dot ru -Status: Bogus +Status: Open Bug Type: Arrays related Operating System: Windows XP SP2 PHP Version: 5.2.0 New Comment: Re-opening this bug. Previous Comments: ------------------------------------------------------------------------ [2007-02-03 01:03:35] den4b at mail dot ru They are strings, that's why they are surrounded with ''. If you are still in doubt - try inserting any string infront of every element, you'll still see the very same effect! The natural-order-aware algorithm that is used for comparing strings has problems. It was addopted from http://sourcefrog.net/projects/natsort/ - I tested it, and it produced the very same bogus results! ------------------------------------------------------------------------ [2007-02-02 23:09:25] tony2001@php.net These numbers are called octal. http://www.php.net/manual/en/language.types.integer.php ------------------------------------------------------------------------ [2007-02-02 22:00:49] den4b at mail dot ru Description: ------------ natsort() does not work for some numbers... Reproduce code: --------------- $a = array('02', '1', '02000', '03'); natsort($a); print_r($a); Expected result: ---------------- Array ( [1] => 1 [0] => 02 [3] => 03 [2] => 02000 ) Actual result: -------------- Array ( [0] => 02 [2] => 02000 [3] => 03 [1] => 1 ) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=40334&edit=1

« previous php.bugs (#108363) next »