php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #49003 natsort: sort sequence has changed
Submitted: 2009-07-21 15:01 UTC Modified: 2009-07-21 21:16 UTC
From: h dot beuttenmueller at gmx dot de Assigned:
Status: Closed Package: Strings related
PHP Version: 5.2.10 OS: winXP SP3
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: h dot beuttenmueller at gmx dot de
New email:
PHP Version: OS:

 

 [2009-07-21 15:01 UTC] h dot beuttenmueller at gmx dot de
Description:
------------
If the following example-array was sorted by 'natsort' with PHP-Version 5.2.9-2 and 5.2.10 the resulting sort sequence is different:

Example-Array
    [0] => 1_3
    [1] => 0_0
    [2] => 3_10
    [3] => 3_4
    [4] => 2_13

natsort - Result with PHP-Version 5.2.9-2
Array
    [1] => 0_0
    [0] => 1_3
    [4] => 2_13
    [3] => 3_4
    [2] => 3_10
 
natsort - Result with PHP-Version 5.2.10
Array
    [0] => 1_3
    [4] => 2_13
    [3] => 3_4
    [2] => 3_10
    [1] => 0_0

Reproduce code:
---------------
#once for PHP-Version 5.2.9-2 and once for 5.2.10
$a = array('1_3','0_0'.'3_10','3_4','2_13');
natsort($a);
print_r($a);

Expected result:
----------------
sort sequence should be the same between both (all:-) versions


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-07-21 20:30 UTC] rasmus@php.net
This is related to fixing bug #44929

I think skipping any punctuation instead of just '.' is probably the right way to go here.  Anything we do is going to be inexact though.  There is no spec for natural sorting to follow.
 [2009-07-21 21:15 UTC] svn@php.net
Automatic comment from SVN on behalf of rasmus
Revision: http://svn.php.net/viewvc/?view=revision&revision=284559
Log: Fix bug #49003 by tweaking the fix to bug #44929 slightly.
A 0 followed by any punctuation is now significant instead
of just 0's in front of a period.
 [2009-07-21 21:16 UTC] rasmus@php.net
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 06:01:30 2024 UTC