Reply to Re: sortign string - why this difference?

Your name:

Reply:


Posted by Sonnich on 12/09/45 11:50

Sonnich wrote:
> 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

I should add the the strings I have are something like:

AB123456
BB345324
BB235342
XX3634543
T44444 <- this is rare, but might happen
TR000001

Sonnich

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация