#!/usr/bin/ruby

func combSort(Array arr) {
    var gap = arr.len;
    var swaps = true;
    while (gap > 1 || swaps) {
        {gap.div!(1.25).int!} -> if (gap > 1);
        swaps = false;
        range(0, arr.end - gap) -> each { |i|
            if (arr[i] > arr[i+gap]) {
                arr[i, i+gap] = arr[i+gap, i];
                swaps = true;
            }
        }
    }
    return arr;
}

var arr = @(1..10).shuffle;
say arr;
combSort(arr);
say arr;
