Doc #69331 [NEW]: Default sort of numbers-as-a-string is not SORT_REGULAR

From: Date: Mon, 30 Mar 2015 12:41:15 +0000
Subject: Doc #69331 [NEW]: Default sort of numbers-as-a-string is not SORT_REGULAR
Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-12062@lists.php.net to get a copy of this message
From: greevex at gmail dot com Operating system: CentOS 6.6 PHP version: 5.5.23 Package: Documentation problem Bug Type: Documentation Problem Bug description:Default sort of numbers-as-a-string is not SORT_REGULAR Description: ------------ --- From manual page: http://www.php.net/function.sort --- I don't really think that it's problem in the sort, but you need to fix documentation with adding information about sorting strings as numeric when values contains numbers only. Test script: --------------- $a = ["1500", "151"]; foreach($a as $item) { echo "Value is " . gettype($item) . PHP_EOL; } echo "default:" . PHP_EOL; sort($a); var_dump($a); echo "regular:" . PHP_EOL; sort($a, SORT_REGULAR); var_dump($a); echo "numeric:" . PHP_EOL; sort($a, SORT_NUMERIC); var_dump($a); echo "string:" . PHP_EOL; sort($a, SORT_STRING); var_dump($a); Expected result: ---------------- Value is string Value is string default: array(2) { [0] => string(4) "1500" [1] => string(3) "151" } regular: array(2) { [0] => string(4) "1500" [1] => string(3) "151" } numeric: array(2) { [0] => string(3) "151" [1] => string(4) "1500" } string: array(2) { [0] => string(4) "1500" [1] => string(3) "151" } Actual result: -------------- Value is string Value is string default: array(2) { [0] => string(3) "151" [1] => string(4) "1500" } regular: array(2) { [0] => string(3) "151" [1] => string(4) "1500" } numeric: array(2) { [0] => string(3) "151" [1] => string(4) "1500" } string: array(2) { [0] => string(4) "1500" [1] => string(3) "151" } -- Edit bug report at https://bugs.php.net/bug.php?id=69331&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=69331&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=69331&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=69331&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=69331&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=69331&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=69331&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=69331&r=needscript Try newer version: https://bugs.php.net/fix.php?id=69331&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=69331&r=support Expected behavior: https://bugs.php.net/fix.php?id=69331&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=69331&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=69331&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=69331&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=69331&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=69331&r=dst IIS Stability: https://bugs.php.net/fix.php?id=69331&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=69331&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=69331&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=69331&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=69331&r=mysqlcfg

« previous php.doc.bugs (#12062) next »