Anonymous user
Sorting algorithms/Shell sort: Difference between revisions
→{{header|Perl}}
m (→{{header|C}}: formatting) |
|||
Line 281:
This method sorts in place. If you want to preserve your unsorted list, copy it first.
<lang perl>use strict;
use warnings;
sub shell { # (int[a])
while ($inc > 0) {
my $temp = $iary[$i];
while
$iary[$
$
}
$iary[$
}
if ($inc == 2) {
$inc = 1;
} else {
$inc *= (5.0 / 11);
$inc = int($inc);
}
}
return
}
my @data = (22, 7, 2, -5, 8, 4);
print "input =@data\n";
@data=shell(@data);
print "output=@data\n"; # [-5, 2, 4, 7, 8, 22]</lang>
=={{header|Python}}==
|