Bug #74042 [NEW]: SORT_NATURAL does not work or pass tests
| From: | ejrx7753 at gmail dot com | Date: | Sat, 04 Feb 2017 00:41:36 +0000 |
| Subject: | Bug #74042 [NEW]: SORT_NATURAL does not work or pass tests | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-207157@lists.php.net to get a copy of this message | ||
From: ejrx7753 at gmail dot com
Operating system: OS X Sierra, Ubuntu 16.04
PHP version: 7.0.15
Package: PDO Core
Bug Type: Bug
Bug description:SORT_NATURAL does not work or pass tests
Description:
------------
A section of "ext/standard/tests/array/sort_basic.phpt" with case
insensitive natural sort does not give the expected result.
Tested on OS X Sierra PHP 7.0.13, PHP 7.1.0, and "PHP
7.0.13-0ubuntu0.16.04.1"
The test expects
[6]=>
string(7) "Orange3"
[7]=>
string(8) "orange20"
But it gives
string(8) "orange20"
[7]=>
string(7) "Orange3"
Obivously expecting "3" before "20" in nat sort. Note also that the
sort_basic does not properly test the insensitive case (as there are no
exeptional elements with case considered) so that was not tested and
assumed also to be not working.
Test script:
---------------
<?php
// associative array containing unsorted string values
$unsorted_strings = array(
"l" => "lemon", "o" => "orange",
"O" => "Orange", "O1" => "Orange1", "o2"
=> "orange2", "O3" =>
"Orange3", "o20" => "orange20",
"b" => "banana",
);
echo "\n-- Testing sort() by supplying string array (natural, case
insensitive), 'flag' = SORT_NATURAL|SORT_FLAG_CASE --\n";
$temp_array = $unsorted_strings;
sort($temp_array, SORT_NATURAL|SORT_FLAG_CASE);
var_dump( $temp_array);
Expected result:
----------------
[6]=>
string(7) "Orange3"
[7]=>
string(8) "orange20"
Actual result:
--------------
string(8) "orange20"
[7]=>
string(7) "Orange3"
--
Edit bug report at https://bugs.php.net/bug.php?id=74042&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=74042&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=74042&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=74042&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=74042&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=74042&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=74042&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=74042&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=74042&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=74042&r=support
Expected behavior: https://bugs.php.net/fix.php?id=74042&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=74042&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=74042&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=74042&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=74042&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=74042&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=74042&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=74042&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=74042&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=74042&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=74042&r=mysqlcfg