in reply to Re: Re: Sort problem
in thread Sort problem

I think the new code you have above gives 'use of uninitialized value' warnings because the array-length check is not quite right. I think it needs instead:

$i++ until $i >= @$a or $i >= @$b or $o = ( $a->[$i] cmp $b->[$i] );

$i == @$a would be just as good as $i >= @$a; I can't decide which is clearer.

Hugo

Replies are listed 'Best First'.
Re: Re^3: Sort problem
by BrowserUk (Patriarch) on Feb 27, 2003 at 08:07 UTC

    Your right. I had it coded as a while loop

    $i++ while ( $i < @$a and $i < @$b ) and not $o=( $a->[$i] cmp $b->[$i] );

    but decided as I was posting it, that it was better done as an until loop as the conditional was slightly clearer.

    Unfortuantely, for the second time yesterday in the same thread I screwed up the conversion.


    ..and remember there are a lot of things monks are supposed to be but lazy is not one of them

    Examine what is said, not who speaks.
    1) When a distinguished but elderly scientist states that something is possible, he is almost certainly right. When he states that something is impossible, he is very probably wrong.
    2) The only way of discovering the limits of the possible is to venture a little way past them into the impossible
    3) Any sufficiently advanced technology is indistinguishable from magic.
    Arthur C. Clarke.