|
Posted by Sonnich on 12/18/48 11:50
Hi!
I have 2 arrays which I sort ny the first one.
for($i=0;$i<(count($item1)-1);$i++)
{
$k = $i;
for($j=$i;$j<(count($item1)-1);$j++);
{
if (strcmp($item1[$k],$item1[$j])<0)
$k = $j;
}
if($k<>$i)
{
$temp=$item1[$i]; $item1[$i]=$item1[$k];
$item1[$k]=$temp;
$temp=$item2[$i]; $item2[$i]=$item2[$k];
$item2[$k]=$temp;
}
}
Pretty simple - it works, I get the highest item first - I'd like it
the other way.
But
if (strcmp($item1[$j],$item1[$k])<0) // k an j switched
does not work, though
if (strcmp($item1[$j],$item1[$k])>0) // < replaced by >
does work, but it is descending
why this?
I can read my array backwards, it is ok, but why this????
BR
Sonnich
[Back to original message]
|