in reply to Re: Re: Newbie Question on pushing Arrays
in thread Newbie Question on pushing Arrays

Your problem is that you keep sorting the list of prime numbers. First of all, this should be unnecessary, since you add them to the list in sequential order.

But in this case, it also causes confusion, since you sorted the list in alphabetical order. Hence, 11 comes before 2. The real solution is to remove both of the sorts from your code.

But if for some reason you actually did need to sort them, you would do this instead:

@primes = sort { $a <=> $b } @primes

Update: It's amazing that I generated the same content as chipmunk did, but that it took me so much longer. I really have to work on my typing skills...

buckaduck

Replies are listed 'Best First'.
Re: Re: Re: Re: Newbie Question on pushing Arrays
by m_heimburger (Initiate) on May 04, 2001 at 21:05 UTC
    Cheers Guys - I changed it and it works fine now. I guess I was trying to solve the problem by sorting... but all I did was create it... :) Thanks again, Martin