Re: the usort 's puzzle
- From: "Rik Wasmus" <luiheidsgoeroe@xxxxxxxxxxx>
- Date: Sun, 30 Sep 2007 14:46:14 +0200
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
.
- References:
- the usort 's puzzle
- From: youngord
- the usort 's puzzle
- Prev by Date: Re: Table schema for user login system?
- Next by Date: Re: Do you use _set?
- Previous by thread: Re: the usort 's puzzle
- Next by thread: Do you use _set?
- Index(es):
Relevant Pages
|