Edit report at https://bugs.php.net/bug.php?id=55158&edit=1

 ID:                 55158
 Patch added by:     ar...@php.net
 Reported by:        joe dot lencioni+php at gmail dot com
 Summary:            Add SORT_NATURAL type to array_multisort
 Status:             Open
 Type:               Feature/Change Request
 Package:            Arrays related
 PHP Version:        5.3.6
 Block user comment: N
 Private report:     N

 New Comment:

The following patch has been added/updated:

Patch Name: php-trunk-array_multisort-natural-case
Revision:   1312473647
URL:        
https://bugs.php.net/patch-display.php?bug=55158&patch=php-trunk-array_multisort-natural-case&revision=1312473647


Previous Comments:
------------------------------------------------------------------------
[2011-07-12 12:00:15] ar...@php.net

The patch I just added implements SORT_NATURAL and also adds SORT_CASE which 
can be combined with SORT_STRING and SORT_NATURAL to make the sorting 
case-insensitive.

------------------------------------------------------------------------
[2011-07-12 11:58:09] ar...@php.net

The following patch has been added/updated:

Patch Name: trunk-multisort-natural
Revision:   1310486289
URL:        
https://bugs.php.net/patch-display.php?bug=55158&patch=trunk-multisort-natural&revision=1310486289

------------------------------------------------------------------------
[2011-07-07 15:00:19] joe dot lencioni+php at gmail dot com

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 this bug report at https://bugs.php.net/bug.php?id=55158&edit=1

Reply via email to