in reply to Simple bubble sort
Things that follow the form:my $temp = @$array[$index + 1]; @$array[$index + 1] = @$array[$index]; @$array[$index] = $temp;
Can be reduced in Perl to:t=a; a=b; b=t;
So shorten that block of code to:(a,b)=(b,a);
($array->[$i+1],$array->[$i])= ($array->[$i],$array->[$i+1]);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Simple bubble sort
by blakem (Monsignor) on Sep 20, 2001 at 09:22 UTC |