Re: the usort 's puzzle



On Sun, 30 Sep 2007 05:37:16 +0200, <youngord@xxxxxxxxx> wrote:

<?php
$mix=array(
array("A",10),
array("B",5),
array("C",100)
);
function com($x,$y){
echo $x[0];
}
usort($mix,'com');


?>

i think the $x[0] result is A,
but the final $x[0] result is BC.
why???

Because PHP uses an internal construct to sort, starting whereever it's internal functionality is written to start, which should not matter. If it compares (B,A) & (C,B), it knows enough to sort.
--
Rik Wasmus
.



Relevant Pages