Sorting algorithms/Comb sort: Difference between revisions

no edit summary
(→‎{{header|Go}}: added more generic version)
No edit summary
Line 741:
 
1 2 3 4 5 6</lang>
 
=={{header|Objeck}}==
<lang objeck>
bundle Default {
class Stooge {
function : Main(args : String[]) ~ Nil {
nums := [3, 5, 1, 9, 7, 6, 8, 2, 4];
CombSort(nums);
each(i : nums) {
IO.Console->Print(nums[i])->Print(",");
};
IO.Console->PrintLine();
}
function : CombSort(input : Int[]) ~ Nil {
gap : Float := input->Size();
swaps := true;
while(gap > 1 | swaps) {
gap /= 1.247330950103979;
if(gap < 1) { gap := 1; };
i : Int := 0;
swaps := false;
while(i + gap < input->Size()) {
igap : Int := i + gap->As(Int);
if (input[i] > input[igap]) {
swap : Int := input[i];
input[i] := input[igap];
input[igap] := swap;
swaps := true;
};
i += 1;
};
};
}
}
}
</lang>
 
=={{header|OCaml}}==
760

edits