[PHP-DOC] Bug #14591 Updated: uasort mixes array with equal elements
by other posts by this author
Jun 17 2002 12:36PM messages near this date
[PHP-DOC] Bug #14591 Updated: uasort mixes array with equal elements
|
[PHP-DOC] Bug #14591 Updated: uasort mixes array with equal elements
ID: 14591
Updated by: hholzgra@[...].net
Reported By: jan@[...].org
-Status: Open
+Status: Closed
Bug Type: Documentation problem
Operating System: Linux/Windows
PHP Version: 4.1.0
Assigned To: hholzgra
New Comment:
documentation fixed in CVS
Previous Comments:
------------------------------------------------------------------------
[2002-06-17 08:24:09] hholzgra@[...].net
implementation and behaviour have changed
but the sort result is still correct,
even if it may be different to what you
get with 4.0.6 or might expect to get
on a first look
there is no easy/efficient way to solve
this issue with the quicksort algorithm
and the documentation says:
" The comparison function must return an integer less than, equal to,
or greater than zero if the first argument is considered to be
respectively less than, equal to, or greater than the second. If two
members compare as equal, their order in the sorted array is
undefined."
i will add an additional warning regarding BC
changed to "ducomentation problem"
------------------------------------------------------------------------
[2002-03-21 21:14:19] eved_hashem@[...].com
I just want to report that the example code for the uasort function in
the PHP manual does not work and nothing gets sorted.. I've tried for
hours and using multiple books to get uasort to work with
multidimensional associative arrays and I have had no success... Am I
possibly printing out the arrays incorrectly?? This is what i Used to
display the sorted array in the example in the PHP manual:
for ( $row = 0; $row < 3; $row++ )
{
while (list($key, value) = each ($array[ $row] ) )
{
echo "|$value";
}
echo "|<BR> ";
}
this can be the only possible thing I find that could be wrong.. if my
code is not incorrect than this is a bug in the program..
------------------------------------------------------------------------
[2001-12-19 05:19:40] mfischer@[...].net
Hartmut, I don't agree with you at all. This is a major BC problem. If
case you haven't checked , PHP 4.0.6 and prior version doesn't change
the sort order. I'ld like to hear what sterling can tell us about
this.
Not bogus, Reopened.
------------------------------------------------------------------------
[2001-12-19 05:05:25] hholzgra@[...].net
well, you can't say that no sorting is needed
in advance as uasort() does not know that
your comparison function is going to return
only zeros
i'm not that deep into qsort implementations
and, yes, i would expect qsort not to swap
elements that are considered equal, but only
for performance reasons ...
(sterling might be able to tell you how and
why zend_qsort does it internaly)
besides that it is totaly ok that you get
a different element order back as is still
a valid order for your sort criteria
good old "garbage in, garbage out" principle ;)
------------------------------------------------------------------------
[2001-12-19 04:31:47] jan@[...].org
Hm, I'd rather expect that an array keeps untouched if there is no need
to sort it.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/14591
--
Edit this bug report at http://bugs.php.net/?id=14591&edit=1
Thread:
|