all tasks
This commit is contained in:
parent
b83f433714
commit
68f8f3e56b
14735 changed files with 178959 additions and 0 deletions
|
|
@ -0,0 +1,16 @@
|
|||
sub combSort {
|
||||
my @arr = @_;
|
||||
my $gap = @arr;
|
||||
my $swaps = 1;
|
||||
while ($gap > 1 || $swaps) {
|
||||
$gap /= 1.25 if $gap > 1;
|
||||
$swaps = 0;
|
||||
foreach my $i (0 .. $#arr - $gap) {
|
||||
if ($arr[$i] > $arr[$i+$gap]) {
|
||||
@arr[$i, $i+$gap] = @arr[$i+$gap, $i];
|
||||
$swaps = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return @arr;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue