|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2017-05-30 07:04 UTC] php-bugs-2014-08 at dotancohen dot com
-Summary: var_export does not export a parsable string
representation of stdClass objects
+Summary: natsort() not ordering as expected
[2017-05-30 07:04 UTC] php-bugs-2014-08 at dotancohen dot com
[2017-06-01 18:23 UTC] danack@php.net
-Status: Open
+Status: Not a bug
[2017-06-01 18:23 UTC] danack@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 08 06:00:01 2025 UTC |
Description: ------------ The order of elements in the array sorted by natsort() is not as expected by the function's name and description. Test script: --------------- <?php $a = array('13.59', '14.6', '14.19'); natsort($a); var_dump($a); $b = array('img0120.jpg','img0.png', 'img0012.png', 'img10.png', 'img2.png', 'img1.png', 'img3.png'); natsort($b); var_dump($b); Expected result: ---------------- array(3) { [0]=> string(5) "13.59" [1]=> string(5) "14.19" [2]=> string(4) "14.6" } array(7) { [0]=> string(8) "img0.png" [1]=> string(8) "img1.png" [2]=> string(8) "img2.png" [3]=> string(8) "img3.png" [4]=> string(9) "img10.png" [5]=> string(11) "img0012.png" [6]=> string(11) "img0120.jpg" } Actual result: -------------- array(3) { [0]=> string(5) "13.59" [1]=> string(4) "14.6" [2]=> string(5) "14.19" } array(7) { [1]=> string(8) "img0.png" [2]=> string(11) "img0012.png" [0]=> string(11) "img0120.jpg" [5]=> string(8) "img1.png" [4]=> string(8) "img2.png" [6]=> string(8) "img3.png" [3]=> string(9) "img10.png" }