Bug #74042 [Com]: SORT_NATURAL does not work or pass tests
| From: | ejrx7753 at gmail dot com | Date: | Sat, 04 Feb 2017 00:45:58 +0000 |
| Subject: | Bug #74042 [Com]: SORT_NATURAL does not work or pass tests | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-207159@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=74042&edit=1
ID: 74042
Comment by: ejrx7753 at gmail dot com
Reported by: ejrx7753 at gmail dot com
Summary: SORT_NATURAL does not work or pass tests
Status: Open
Type: Bug
Package: Arrays related
Operating System: OS X Sierra, Ubuntu 16.04
PHP Version: 7.0.15
Block user comment: N
Private report: N
New Comment:
Correction - does not properly test the "case sensitive" call. Just a side note not
central to the report.
Previous Comments:
------------------------------------------------------------------------
[2017-02-04 00:42:59] ejrx7753 at gmail dot com
(fixed package meta)
------------------------------------------------------------------------
[2017-02-04 00:41:34] ejrx7753 at gmail dot com
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 this bug report at https://bugs.php.net/bug.php?id=74042&edit=1