Shining Arcanine
Thu 24th Jul '03, 10:11pm
In a nonvB script I am coding, sort() fails to operate. So does asort which is very similar to it. I am unable to reproduce my this issue in any script other than the one I am having it in.
I had 2 loops print the data that in the array before and after using sort and it stayed the same. Then I simulated what the area the problem was did and then printed the data with the same loops in a test script and it printed what I expected it to print.
http://us3.php.net/manual/en/function.sort.php
At the bottom "x-itec at freenet dot de" says:
Maybe u have a problem that you can not sort your array if the array contains only numbers. The solution: The numbers are sorted as ASCII, you have to store values to your array in this form as an example:
$artikelarray[$x]=intval($row188[id]);
You have to use INTVAL to convert your Number to a numeric value! Now you can sort your array with sort($artikelarray) and it works finde.
Boris Köster
I didn't think his workaround would work and lo and behold, it didn't. How do I get around this?
Edit: Here is the mutidimesional array that is generated on the fly which I am testing with:
$list=array(array(1,0),
array(10,1),
array(20,2),
array(30,3),
array(40,5),
array(50,4),
);
In another script, this will work with sort() but not in the script that I need it to work in. An extremely complex process is done to generate it so I can't simply put it in another script since this is part of an extremely complex script.
I had 2 loops print the data that in the array before and after using sort and it stayed the same. Then I simulated what the area the problem was did and then printed the data with the same loops in a test script and it printed what I expected it to print.
http://us3.php.net/manual/en/function.sort.php
At the bottom "x-itec at freenet dot de" says:
Maybe u have a problem that you can not sort your array if the array contains only numbers. The solution: The numbers are sorted as ASCII, you have to store values to your array in this form as an example:
$artikelarray[$x]=intval($row188[id]);
You have to use INTVAL to convert your Number to a numeric value! Now you can sort your array with sort($artikelarray) and it works finde.
Boris Köster
I didn't think his workaround would work and lo and behold, it didn't. How do I get around this?
Edit: Here is the mutidimesional array that is generated on the fly which I am testing with:
$list=array(array(1,0),
array(10,1),
array(20,2),
array(30,3),
array(40,5),
array(50,4),
);
In another script, this will work with sort() but not in the script that I need it to work in. An extremely complex process is done to generate it so I can't simply put it in another script since this is part of an extremely complex script.