-
Numerical sort issue...
Hi.
I defined an array construct and assigned two variables to part of the array so I can simple sort it:
number1 = array[i]
number2 = array[i+1]
if(number1 > number2){
...swap etc
Problem is, when I try the comparason if the one of the numbers has a higher digit value, it ignores the statement entirely. Eg If 16 > 8 it skips it. So I tried adding '16' and '08' into the array and that worked perfectly with the statement.
Any ideas?
Thanks guys
-
It might treat number1 and/or number2 as strings. Hard to tell without your complete code.
Anyway, if that's the case, try this:
PHP Code:
if(Number(number1) > Number(number2)){
-
awesome that worked, thank you
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|