Sorting algorithms/Comb sort: Difference between revisions

Content added Content deleted
(Added a solution for MATLAB)
(→‎{{header|MATLAB}}: Optimized the swap)
Line 387: Line 387:
if (list(i) > list(i+gap))
if (list(i) > list(i+gap))
temp = list(i);
list([i i+gap]) = list([i+gap i]); %swap
list(i) = list(i+gap);
list(i+gap) = temp;
swaps = true;
swaps = true;
end
end