Req #73128 [NEW]: Add a sort method to the SPL Datastructures
| From: | carlosv775 at gmail dot com | Date: | Tue, 20 Sep 2016 13:22:57 +0000 |
| Subject: | Req #73128 [NEW]: Add a sort method to the SPL Datastructures | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-204151@lists.php.net to get a copy of this message | ||
From: carlosv775 at gmail dot com
Operating system: Irrelevant
PHP version: Irrelevant
Package: SPL related
Bug Type: Feature/Change Request
Bug description:Add a sort method to the SPL Datastructures
Description:
------------
Some Datastructures like SplFixedArray and SplObjectStorage could have a
sort method where we can pass an optional callback and it sorts the
original object or even return a new one.
Test script:
---------------
<?php
$array = new SplFixedArray(10);
for ($i = 0; $i < 10; $i++) {
$array[$i] = mt_rand(1, 10);
};
$array->sort();
$array->sort(function ($a, $b) { return $b - $a; });
/**
* Or:
* $newArray = $array->sort();
*/
Expected result:
----------------
A sorted SPL Datastructure
Actual result:
--------------
FATAL ERROR Uncaught Error: Call to undefined method
SplFixedArray::sort()
--
Edit bug report at https://bugs.php.net/bug.php?id=73128&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=73128&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=73128&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=73128&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=73128&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=73128&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=73128&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=73128&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=73128&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=73128&r=support
Expected behavior: https://bugs.php.net/fix.php?id=73128&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=73128&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=73128&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=73128&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=73128&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=73128&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=73128&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=73128&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=73128&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=73128&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=73128&r=mysqlcfg