mirror of
https://github.com/php/php-src.git
synced 2026-03-26 09:12:14 +01:00
Make user-exposed sorts stable, by storing the position of elements in the original array, and using those positions as a fallback comparison criterion. The base sort is still hybrid q/insert. The use of true/false comparison functions is deprecated (but still supported) and should be replaced by -1/0/1 comparison functions, driven by the <=> operator. RFC: https://wiki.php.net/rfc/stable_sorting Closes GH-5236.
13 lines
166 B
PHP
13 lines
166 B
PHP
--TEST--
|
|
asort() is stable
|
|
--FILE--
|
|
<?php
|
|
|
|
$array = $origArray = array_fill(0, 1000, null);
|
|
asort($array);
|
|
var_dump($array === $origArray);
|
|
|
|
?>
|
|
--EXPECT--
|
|
bool(true)
|