From:
Operating system:
PHP version: 5.3.6
Package: Arrays related
Bug Type: Feature/Change Request
Bug description:Add SORT_NATURAL type to array_multisort
Description:
------------
Arrays often need to be sorted using a "natural order" algorithm. There are
currently functions in PHP for sorting single arrays this way (natsort,
natcasesort), but nothing exists for a multisort.
It would be great to see a SORT_NATURAL option in the array_multisort
function.
Test script:
---------------
$a = array(
'Second',
'First',
'Twentieth',
'Tenth',
'Third',
);
$b = array(
'2 a',
'1 b',
'20 c',
'10 d',
'3 e',
);
array_multisort($b, SORT_NATURAL, $a);
var_dump($a, $b);
Expected result:
----------------
array
0 => string 'First' (length=5)
1 => string 'Second' (length=6)
2 => string 'Third' (length=5)
3 => string 'Tenth' (length=5)
4 => string 'Twentieth' (length=9)
array
0 => string '1 b' (length=3)
1 => string '2 a' (length=3)
2 => string '3 e' (length=3)
3 => string '10 d' (length=4)
4 => string '20 c' (length=4)
--
Edit bug report at https://bugs.php.net/bug.php?id=55158&edit=1
--
Try a snapshot (PHP 5.2):
https://bugs.php.net/fix.php?id=55158&r=trysnapshot52
Try a snapshot (PHP 5.3):
https://bugs.php.net/fix.php?id=55158&r=trysnapshot53
Try a snapshot (trunk):
https://bugs.php.net/fix.php?id=55158&r=trysnapshottrunk
Fixed in SVN:
https://bugs.php.net/fix.php?id=55158&r=fixed
Fixed in SVN and need be documented:
https://bugs.php.net/fix.php?id=55158&r=needdocs
Fixed in release:
https://bugs.php.net/fix.php?id=55158&r=alreadyfixed
Need backtrace:
https://bugs.php.net/fix.php?id=55158&r=needtrace
Need Reproduce Script:
https://bugs.php.net/fix.php?id=55158&r=needscript
Try newer version:
https://bugs.php.net/fix.php?id=55158&r=oldversion
Not developer issue:
https://bugs.php.net/fix.php?id=55158&r=support
Expected behavior:
https://bugs.php.net/fix.php?id=55158&r=notwrong
Not enough info:
https://bugs.php.net/fix.php?id=55158&r=notenoughinfo
Submitted twice:
https://bugs.php.net/fix.php?id=55158&r=submittedtwice
register_globals:
https://bugs.php.net/fix.php?id=55158&r=globals
PHP 4 support discontinued:
https://bugs.php.net/fix.php?id=55158&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=55158&r=dst
IIS Stability:
https://bugs.php.net/fix.php?id=55158&r=isapi
Install GNU Sed:
https://bugs.php.net/fix.php?id=55158&r=gnused
Floating point limitations:
https://bugs.php.net/fix.php?id=55158&r=float
No Zend Extensions:
https://bugs.php.net/fix.php?id=55158&r=nozend
MySQL Configuration Error:
https://bugs.php.net/fix.php?id=55158&r=mysqlcfg
Try a snapshot (PHP 5.4):
https://bugs.php.net/fix.php?id=55158&r=trysnapshot54